cron-expression-validator
cron-expression-validator is a Node.JS library to validate quartz cron expressions
Installation
npm install cron-expression-validator
Usage
isValidCronExpression method reqire string (cron expression) as parameter and returns boolean value
var cronValidator = require('cron-expression-validator');
var isValid = cronValidator.isValidCronExpression("* * * * * ? *");
if(cronValidator.isValidCronExpression("* * * * * ? *")) {
}
if(cronValidator.isValidCronExpression("* * * * * * *")) {
}
Optional second param if you want to get error message
Can get error message by passing { error: true }
as second parameter
if(cronValidator.isValidCronExpression("* * * * 25/2 ? *", {error: true}) {
}
if(cronValidator.isValidCronExpression("* * * ? * * 123/555", {error: true}) {
}
if(cronValidator.isValidCronExpression("0 0 12 1/2 * ? *", {error: false}) {
}
Cron accepted values
Seconds: 0-59
Minutes: 0-59
Hours: 0-23
Day of Month: 1-31, L, LW
Months: (JAN-DEC and 1-12)
Day of Week: (SUN-SAT and 1-7)
Year: 1970-2099