Closed mauserzjeh closed 1 year ago
Thanks for the question, but with default validators, it's not possible, but using a custom validation function you could do that if you really wish to. https://pkg.go.dev/github.com/go-playground/validator/v10#hdr-Custom_Validation_Functions
Is it possible when using the
required_if
validator (or any other validator that will use another field as a parameter) to use thejson
tag value as a parameter instead of the field's name?For example:
By default I can only use
"required_if=AField foo"
for the binding to make it work. Is it possible to somehow use thejson
tag value for a validator like this? So the binding would become"required_if=a_field foo"
I have already registered a
TagNameFunc
but I guess thats only works when returning error messages. Thanks in advance!