An hexadecimal tag signals an invalid input over missing field even without the required tag
Code sample, to showcase or reproduce:
Over a ConfUp struct w/ optional hexadecimal Fopts field and a {} input, the validation returns a non-nil err.
type ConfUp struct{
Fopts string `json:"fopts" validate:"hexadecimal"`
}
func (e *ConfUp) Validate() error {
return validator.New().Struct(e)
}
func (e *ConfUp) FromByte(src []byte) error {
return json.Unmarshal(src, e)
}
func (e *ConfUp) Byte() ([]byte, error) {
return json.Marshal(e)
}
...
cu := &ConfUp{}
if ierr = cu.FromByte(payload); ierr == nil {
if verr = cu.Validate(); verr == nil {
return nil
}
}
...
I expected no check over a missing field for no required tag. Moreover, a numeric tag does not trigger the same behavior. Are there some docu coverage over this logic?
Package version:
v10
Issue, Question or Enhancement:
An hexadecimal tag signals an invalid input over missing field even without the required tag
Code sample, to showcase or reproduce:
Over a ConfUp struct w/ optional hexadecimal Fopts field and a
{}
input, the validation returns a non-nil err.I expected no check over a missing field for no required tag. Moreover, a numeric tag does not trigger the same behavior. Are there some docu coverage over this logic?
The omitempty tag bypasses the issue