validator
validator copied to clipboard
Align required_without with usage shown in the docs
Fixes Or Enhances
Resolves #617
Fixes required_without
so that it aligns with the stated contract and usage examples.
The docs valid usage to be:
// require the field if the Field1 is not present:
Usage: required_without=Field1
// require the field if the Field1 or Field2 is not present:
Usage: required_without=Field1 Field2
However, as show in this issue: https://github.com/go-playground/validator/issues/617, you can only use required_without
on multiple fields like:
type Test struct {
Field1 string `validator:required_without=Field2,required_without=Field3"
...
}
This PR aligns the behavior of the required_without
validator such that you can also use it as shown in the example:
type Test struct {
Field1 string `validator:required_without=Field2 Field3"
...
}
Make sure that you've checked the boxes below before you submit PR:
- [x] Tests exist or have been written that cover this particular change.
@go-playground/validator-maintainers