1.1.5 • Published 5 months ago

ts-cron-validator v1.1.5

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

ts-cron-validator

A TypeScript type level CRON expression validator!

VSCode screenshot!

Expressions supported are the one generated and describe on crontab.guru website. This means that you can use this library to check standard CRON expressions but also non standard one. Also, this type level validator works quite well in conjunction with cron engines such as node-cron.

For a live demo, you can try this codesandbox

Usage

To install this tiny library:

  
  npm install ts-cron-validator

Then you have the choice between two helper functions:

  • validStandardCronExpression() if you use a scheduler that understands only standard CRON expressions.
  • validCronExpression() if you use a scheduler that also understands non standard expressions.

Below some examples that show how to use those two helpers:

import { validCronExpression, validStandardCronExpression } from 'ts-cron-validator';

validStandardCronExpression('0 3 * * * ');      // OK padding accepted
validStandardCronExpression('42 * * *   ');     // KO missing day of week part
validStandardCronExpression('59 4 * * *');      // OK
validStandardCronExpression('60 4 * * *');      // KO incorrect minutes part 

validCronExpression('20 59 4 * dec mon');       // OK non standard CRON expression are accepted
                                                // by validCronExpression()
1.1.5

5 months ago

1.1.4

6 months ago

1.1.3

6 months ago

1.1.2

6 months ago

1.1.1

6 months ago

1.1.0

6 months ago

1.0.0

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago