Hey @anam-digicom you would need to use the dive tag documented here
basic example:
type User struct {
Foo []string `validate"required,dive,ne=bar"`
}
let me know if that helps.
Hey @joeybloggs
This works with a struct containing a slice field, but how to validate a slice using validate.Struct(mySliceOfStructs) ?
Thanks!
@denouche because your validating a variable at this point you would use validate.Var(mySliceOfStructs, “required,dive”) or if not required use “omitempty,dive”
Nice, it works great.
So fast to answer, great answers, nice library!
Thank you!
Most helpful comment
Nice, it works great.
So fast to answer, great answers, nice library!
Thank you!