Skip to content

Commit

Permalink
fix: cron parsing number range [DHIS2-18859]
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp authored Jan 21, 2025
2 parents f029f67 + 0593b44 commit a87fa32
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/validators/validate-cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const isValidNumberRange = (range, x, y) => {
return (
isValidNumber(boundaries[0], x, y) &&
isValidNumber(boundaries[1], x, y) &&
boundaries[0] <= boundaries[1]
Number(boundaries[0]) <= Number(boundaries[1])
)
}

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 @@ -36,6 +36,10 @@ describe('validateCron', () => {
expect(validateCron('0 0 1-5 * * *')).toBe(true)
})

it('should parse numbers properly in number ranges', () => {
expect(validateCron('0 0 4-23 * * *')).toBe(true)
})

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

1 comment on commit a87fa32

@dhis2-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.