Closed siampudan closed 3 years ago
This is by design, see: https://github.com/go-ozzo/ozzo-validation/blob/master/required.go#L14-L20
You should use NotNil
in your case: https://github.com/go-ozzo/ozzo-validation/blob/master/not_nil.go#L13
hmm, i see. thanks..
I've a struct like this :
and validation struct like this :
When i create a request from Postman and set json body payload
"is_available" : true
the validation.Required treat the IsAvailable field as it is. But, when i set"is_available":false
the validation.Required treat the IsAvailable field as blank value{ "is_available": "cannot be blank" }
. It looks like the validation.Required failed to detect the *bool type when it set to 'false'. To parse the request json payload to the model struct, i use Gin Framework (ShouldBindJSON). Thanks.