Skip to content

Commit

Permalink
fix(validate cron): allow ranges in fraction numerators
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed Nov 7, 2022
1 parent 4c4d6fd commit 7f01c2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/services/validators/validate-cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ const isValidFraction = (fraction, x, y) => {

/* istanbul ignore next */
return (
(isWildcard(components[0]) || isValidNumber(components[0], x, y)) &&
(isWildcard(components[0]) ||
isValidNumber(components[0], x, y) ||
isValidNumberRange(components[0], x, y)) &&
isValidNumber(components[1], x, y)
)
}
Expand Down
4 changes: 4 additions & 0 deletions src/services/validators/validate-cron.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ describe('validateCron', () => {
it('should allow for number ranges', () => {
expect(validateCron('0 0 1-5 * * *')).toEqual(true)
})

it('should allow ranges in fraction numerators', () => {
expect(validateCron('0 0 10-22/2 ? * *')).toBe(true)
})
})

0 comments on commit 7f01c2f

Please sign in to comment.