v9
Question
Is there an easy way to specify a list of valid values?
E.g. valid values are _us,uk,fr,mv,es,de,be_
type Request struct {
Country string validate:"required,oneof=us,uk,fr,mv,es,de,be"`
}
Ignore my question.
I just noticed there is oneof tag already (I missed it in documentation first 29 times)
So, valid code for previous example would be:
type Request struct {
Country string `validate:"required,oneof=us uk fr mv es de be"`
}
Most helpful comment
Ignore my question.
I just noticed there is
oneoftag already (I missed it in documentation first 29 times)So, valid code for previous example would be: