Open adrianbielsa1 opened 2 years ago
When you initialize data as 0 it treat is as an empty value when doing the validation. Hence you are getting nil.
Then, how would you validate that a value must be greater than 0?
You can do something like this. Since it is treating 0 as empty.
data := float64(0)
err := validation.Validate(data,
validation.Min(float64(0)).Exclusive(),
validation.NilOrNotEmpty.Error("must be greater than 0"),
)
fmt.Println(err)
Hi! I stumbled upon the following situation: validating a number's minimum threshold does not work as intended when said threshold is 0.
The following snippet works as expected, printing "must be greater than 1":
However, changing the threshold to 0 nullifies the error:
^ prints "\" (i.e. no error).