govalidator
govalidator copied to clipboard
not support for range now?
type Item struct {
Bt int `valid:"range(1|100)"`
}
func main() {
t := Item{-1}
ok, err := govalidator.ValidateStruct(t)
fmt.Println(ok, err)
}
output:Bt: Validator range(1|100) doesn't support kind int;
There is a support for InRange
but it works only with float numbers.
https://github.com/asaskevich/govalidator/blob/aa5cce4a76edb1a5acecab1870c17abbffb5419e/numerics.go#L42
I think there must be different functions for float and decimal numbers e.g. InRangeFloat32
and InRangeInt
Submitted pull request #239
Merged, thanks!
But there is no definition of functions to use them in struct tags, will be resolved
Do I get it correctly that I can't do the simplest thing - validate an int* field in struct against a range - with govalidator? :)
I've created a PR with a quick & dirty fix: https://github.com/asaskevich/govalidator/pull/263
Please close the issue. It's fixed. @asaskevich
Hello guys! I forked this package cause owner disappeared. Hope, he will be back, but it would be easier to merge these changes back if he is back Link to my repo: create issue there and we'll discuss it.