From 54c6452a40c845a0f0d372342240438ed69fc42f Mon Sep 17 00:00:00 2001 From: sg3-141-592 <5122866+sg3-141-592@users.noreply.github.com> Date: Fri, 20 Sep 2024 07:47:09 +0100 Subject: [PATCH] Fix for potential negative step in cron --- gronx_test.go | 3 +++ validator.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gronx_test.go b/gronx_test.go index 80a3ce6..5464b9d 100644 --- a/gronx_test.go +++ b/gronx_test.go @@ -91,6 +91,9 @@ func TestIsValid(t *testing.T) { if gron.IsValid("* * * *") { t.Errorf("expected false, got true") } + if gron.IsValid("0-0/-005 * * * *") { + t.Errorf("expected true, got false") + } }) } diff --git a/validator.go b/validator.go index 62c3a36..d7441d4 100644 --- a/validator.go +++ b/validator.go @@ -14,7 +14,7 @@ func inStep(val int, s string, bounds []int) (bool, error) { if err != nil { return false, err } - if step == 0 { + if step <= 0 { return false, errors.New("step can't be 0") }