Skip to content

Commit

Permalink
fix: loosen frontend cron validation (#13792)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephkmh committed Sep 2, 2024
1 parent 47fa764 commit 8ccc517
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ describe("validateCronExpression", () => {
${"0 0 9 * * ?"} | ${true} | ${undefined}
${"0 0 9 ? * 5"} | ${true} | ${undefined}
${"0 1 0 * * ?"} | ${true} | ${undefined}
${"* * * 1 * ?"} | ${true} | ${undefined}
${"* * * 10 * ?"} | ${true} | ${undefined}
${"* * * 31 * ?"} | ${true} | ${undefined}
${"0 15,45 7-17 ? * MON-FRI"} | ${true} | ${undefined}
${"0 15 6 * * ?"} | ${true} | ${undefined}
${"0 30 1 * * ?"} | ${true} | ${undefined}
Expand All @@ -64,7 +67,7 @@ describe("validateCronExpression", () => {
${"* * * * * * *"} | ${true} | ${undefined}
${"wildly invalid"} | ${false} | ${'Cron expression "wildly invalid" must contain at least 6 fields (2 fields found)'}
${"* * * * *"} | ${false} | ${'Cron expression "* * * * *" must contain at least 6 fields (5 fields found)'}
${"0 0 0 0 0 0"} | ${false} | ${'"0" did not match regex at index 3'}
${"0 0 0 0 0 0"} | ${false} | ${'"0" did not match regex at index 4'}
${"* * * * * * ?"} | ${false} | ${'"?" did not match regex at index 6'}
`("'$expression' is valid: $isValid", ({ expression, isValid, message }) => {
expect(validateCronExpression(expression).isValid).toEqual(isValid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const CRON_REGEX_MAP = [
/^(([0-9]|,|-|\*|\/)+)$/, // seconds
/^(([0-9]|,|-|\*|\/)+)$/, // minutes
/^(([0-9]|,|-|\*|\/)+)$/, // hours
/^(([1-9]|,|-|\*|\/|\?|L|W)+)$/, // day of month
/^(([0-9]|,|-|\*|\/|\?|L|W)+)$/, // day of month
/^(([1-9]|,|-|\*|\/|JAN|FEB|MAR|APR|JUN|JUL|AUG|SEP|OCT|NOV|DEC)+)$/, // month
/^(([1-7]|,|-|\*|\/|\?|L|#|SUN|MON|TUE|WED|THU|FRI|SAT|SUN)+)$/, // day of week
/^(([0-9]|,|-|\*|\/)+)/, // year
Expand Down

0 comments on commit 8ccc517

Please sign in to comment.