diff --git a/pkg/ocm/validators.go b/pkg/ocm/validators.go index 3656056b8f..637768f97a 100644 --- a/pkg/ocm/validators.go +++ b/pkg/ocm/validators.go @@ -68,8 +68,8 @@ func PercentageValidator(val interface{}) error { return fmt.Errorf("Failed parsing '%v' into a floating-point number.", val) } - if number > 1 || number < 0 { - return fmt.Errorf("Expecting a floating-point number between 0 and 1.") + if number >= 1 || number <= 0 { + return fmt.Errorf("Expecting a floating-point number greater than 0 and less than 1.") } return nil diff --git a/pkg/ocm/validators_test.go b/pkg/ocm/validators_test.go index 257e67576c..6856dbaf37 100644 --- a/pkg/ocm/validators_test.go +++ b/pkg/ocm/validators_test.go @@ -89,6 +89,14 @@ var _ = Describe("Input Validators", Ordered, func() { Expect(PercentageValidator("-0.1")).ToNot(BeNil()) }) + It("raises an error if got exactly 0", func() { + Expect(PercentageValidator("0")).ToNot(BeNil()) + }) + + It("raises an error if got exactly 1", func() { + Expect(PercentageValidator("1")).ToNot(BeNil()) + }) + It("successfully parses a valid percentage value", func() { Expect(PercentageValidator("0.4")).To(BeNil()) })