-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gvalid not supported required-without rule in struct field #2503
Comments
It is recommended to change the validator to the form of interface parameters so that users can use other third-party verification libraries. Personally, the library of goplaground/validator is easier to use. |
@StrangeYear Please provide a copy of shortest codes for reproducing the error. A complete runnable program is best. |
type Foo struct {
Bar *Bar `p:"bar" v:"required-without:Baz"`
Baz *Baz `p:"baz" v:"required-without:Bar"`
}
type Bar struct {
BarKey string `p:"bar_key" v:"required"`
}
type Baz struct {
BazKey string `p:"baz_key" v:"required"`
}
func TestValidate(t *testing.T) {
foo := &Foo{
Bar: &Bar{BarKey: "value"},
}
err := gvalid.New().Data(foo).Bail().Run(context.Background())
if err != nil {
t.Fatal(err)
}
} Output: The BazKey field is required |
@StrangeYear I'm dealing with this, but it needs some time. |
Although I set the value of one field, the other field will still be verified.
problem file: gvalid_validator_check_struct.go
The text was updated successfully, but these errors were encountered: