Open jejefferson opened 6 years ago
Validation error depends on capital/lower case field name of struct. In this example second validation fails:
package main
import (
"fmt"
"github.com/asaskevich/govalidator"
)
type StructLower struct {
total float32 `valid:"float,required"`
}
type StructCapital struct {
Total float32 `valid:"float,required"`
}
func main() {
testStruct := StructLower{total: 45.32}
_, err := govalidator.ValidateStruct(&testStruct)
if err != nil {
fmt.Println(err.Error())
}
testStruct2 := StructCapital{Total: 53.3535}
_, err = govalidator.ValidateStruct(&testStruct2)
if err != nil {
fmt.Println(err.Error())
}
}
Fixed, pull request #268 includes unit tests
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.
I have an a problem with validate float field in structure:
My originally json looks like this:
After binding to struct and validation it validator raise an exception:
In delve debugger I really have a float type before validation:
My go version: go1.10 darwin/amd64.