Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ cronExp.build();
// '* * * * *'
```

The cron values are stored with the following keys, which must match identically when getting and setting:
```JavaScript
'minute', 'hour', 'dayOfTheMonth', 'month', 'dayOfTheWeek'
```

API includes basic getters and setters:
```JavaScript
cronExp.get('minute');
Expand Down
12 changes: 9 additions & 3 deletions cron-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var CronValidator = (function() {

for (var measureOfTime in expression) {
if (expression.hasOwnProperty(measureOfTime)) {
this.validateValue(measureOfTime, expression[measureOfTime]);
this.validateValue(measureOfTime, expression[measureOfTime][0]);
}
}
},
Expand Down Expand Up @@ -89,6 +89,14 @@ var CronValidator = (function() {
throw new Error('Invalid value; Only numbers 0-9, "-", and "*" chars are allowed');
}

if (!measureOfTime || !value) {
throw new Error('Missing arguments; Both measureOfTime and value are required arguments');
}

if (typeof(value) !== 'string') {
throw new Error('value argument must be a string');
}

if (value !== '*') {
// check to see if value is within range if value is not '*'
if (value.indexOf('-') >= 0) {
Expand All @@ -102,7 +110,6 @@ var CronValidator = (function() {
throw new Error('Invalid value; top of range is not valid for "' + measureOfTime + '". Limit is ' + validatorObj[measureOfTime].max + '.');
}
} else {

if (parseInt(value) < validatorObj[measureOfTime].min) {
throw new Error('Invalid value; given value is not valid for "' + measureOfTime + '". Minimum value is "' + validatorObj[measureOfTime].min + '".');
}
Expand All @@ -113,7 +120,6 @@ var CronValidator = (function() {
}
};


return {
measureOfTimeValues: MeasureOfTimeValues,
validateExpression: validateExpression,
Expand Down