An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.
MIT License
3.73k
stars
224
forks
source link
Validation error of structs with integer constants. #67
For whatever reason, validating integer constants fails when the value is 0. The following returns with "Code" is required (or something similar). If I change my constants to 1,2 instead of 0,1 it works fine, and if it change OK to NOT_OK in the example (keeping 0,1) below it works fine too.
type ResponseCode int
const (
OK ResponseCode = 0
NOT_OK ResponseCode = 1
)
type data struct {
code: OK,
something: "foo"
}
func (d Data) Validate() error {
validation.ValidateStruct(&d,
validation.Field(&d.code, validation.Required),
)
}
For whatever reason, validating integer constants fails when the value is 0. The following returns with "Code" is required (or something similar). If I change my constants to 1,2 instead of 0,1 it works fine, and if it change OK to NOT_OK in the example (keeping 0,1) below it works fine too.