validate
validate copied to clipboard
[Question] Can `in` be used with slice in tag validation?
type A struct{
S []string `validate:"required|in:a,b"`
}
I basically want each element of S
to be either a
or b
, but looks like in
validation in the tag by default does not support validating a slice, I know you can do it using the programmatic validation (StringRule()
), but I want to stick with tag validation, is there any workaround for it?