-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
- I have looked at the documentation here first?
- I have looked at the examples provided that may showcase my question here?
Package version eg. v9, v10:
v10 (v10.11.0)
Issue, Question or Enhancement:
There seems to be a problem with the required_without validation. It might also affect other rules that validate a field against other fields.
Please see the code examples below for expected and observed behavior.
If more information is needed I'm happy to provide it. Thanks for your help!
Code sample, to showcase or reproduce:
Example 1
v := validator.New()
dataMap := map[string]interface{}{
"foo": "bar",
"foo2": "",
}
validationRules := map[string]interface{}{
"foo": "required_without=foo2",
}
res := v.ValidateMap(dataMap, validationRules)results in
panic: Invalid field namespace
Expected result would be an empty res because everything is fine.
Example 2
v := validator.New()
dataMap := map[string]interface{}{
// "foo": "",
"foo2": "bar",
}
validationRules := map[string]interface{}{
"foo": "required_without=foo2",
}
res := v.ValidateMap(dataMap, validationRules)
fmt.Printf("%+v\n", res)results in (no difference if foo is provided or not)
map[foo:Key: '' Error:Field validation for '' failed on the 'required_without' tag]
Expected result would be an empty res because everything is fine.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels