You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looks like for some use-cases govalidator tries to unmarshal request body fields into Go struct fields before running validation. I have a struct: type S struct { Foo bool `json:"foo"` }
And the following rules: rules := govalidator.MapData{"foo": []string{"bool"}}
On request, foo could be specified as a value of any type, govalidator should notice that a value cannot be cast to a boolean. But because the struct value is of type bool (and not string, interface{}, etc.), govalidator does not run validation, it first tries to unmarshal the value into a proper bool value of the struct, which fails if the provided value is a string, for example. Should the order be different? Should it stop at the validation error without failing on an unmarshalling error?
The text was updated successfully, but these errors were encountered:
Looks like for some use-cases govalidator tries to unmarshal request body fields into Go struct fields before running validation. I have a struct:
type S struct { Foo bool `json:"foo"` }
And the following rules:
rules := govalidator.MapData{"foo": []string{"bool"}}
On request,
foo
could be specified as a value of any type, govalidator should notice that a value cannot be cast to a boolean. But because the struct value is of typebool
(and notstring, interface{}
, etc.), govalidator does not run validation, it first tries to unmarshal the value into a proper bool value of the struct, which fails if the provided value is a string, for example. Should the order be different? Should it stop at the validation error without failing on an unmarshalling error?The text was updated successfully, but these errors were encountered: