Closed mixedCase closed 1 year ago
Can you give an example of this issue?
validation.Min(1).Validate(0)
should logically return an error given that 0 is less than 1, but because 0 is the zero value for the int type, it does not.
A workaround is to use the rule validation.Required
in conjunction with validation.Min
, of course, but API-wise this doesn't make much sense and breaks the principle of least surprise in a big way.
That's the intended behaviour, as stated in the doc comments: https://github.com/jellydator/validation/blob/f3d1c3d00ac7acf4dbcc16a5c1f75ef39d37edd9/minmax.go#L32-L37
// An empty value is considered valid. Please use the Required rule to make sure a value is not empty.
Title.