Skip to content

Commit 51697fb

Browse files
authored
fix: cron validation support for star step value (#1302)
## Fixes Or Enhances Resolves #1259 **Make sure that you've checked the boxes below before you submit PR:** - [x] Tests exist or have been written that cover this particular change. @go-playground/validator-maintainers
1 parent f1939ee commit 51697fb

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

regexes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const (
7373
cveRegexString = `^CVE-(1999|2\d{3})-(0[^0]\d{2}|0\d[^0]\d{1}|0\d{2}[^0]|[1-9]{1}\d{3,})$` // CVE Format Id https://cve.mitre.org/cve/identifiers/syntaxchange.html
7474
mongodbIdRegexString = "^[a-f\\d]{24}$"
7575
mongodbConnStringRegexString = "^mongodb(\\+srv)?:\\/\\/(([a-zA-Z\\d]+):([a-zA-Z\\d$:\\/?#\\[\\]@]+)@)?(([a-z\\d.-]+)(:[\\d]+)?)((,(([a-z\\d.-]+)(:(\\d+))?))*)?(\\/[a-zA-Z-_]{1,64})?(\\?(([a-zA-Z]+)=([a-zA-Z\\d]+))(&(([a-zA-Z\\d]+)=([a-zA-Z\\d]+))?)*)?$"
76-
cronRegexString = `(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every (\d+(ns|us|µs|ms|s|m|h))+)|((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5,7})`
76+
cronRegexString = `(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every (\d+(ns|us|µs|ms|s|m|h))+)|((((\d+,)+\d+|((\*|\d+)(\/|-)\d+)|\d+|\*) ?){5,7})`
7777
spicedbIDRegexString = `^(([a-zA-Z0-9/_|\-=+]{1,})|\*)$`
7878
spicedbPermissionRegexString = "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$"
7979
spicedbTypeRegexString = "^([a-z][a-z0-9_]{1,61}[a-z0-9]/)?[a-z][a-z0-9_]{1,62}[a-z0-9]$"

validator_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -13656,6 +13656,7 @@ func TestCronExpressionValidation(t *testing.T) {
1365613656
{"*/20 * * * *", "cron", true},
1365713657
{"0 15 10 ? * MON-FRI", "cron", true},
1365813658
{"0 15 10 ? * 6#3", "cron", true},
13659+
{"0 */15 * * *", "cron", true},
1365913660
{"wrong", "cron", false},
1366013661
}
1366113662

0 commit comments

Comments
 (0)