You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect that either both scenarios would throw errors with all scenarios, or the excluded_unless behaves similarly to the latter, in that only TestC should throw errors.
Suggested Proposal
First, I think we should update the implementations to have similar behavior. Secondly, I think the documentation in general lacks instruction for validating multiple values for a single field. Perhaps the answer is to simply use the OR operator | and redeclare the validation tag, but either way it should be documented.
Package version eg. v9, v10:
v10
Issue, Question or Enhancement:
When validating multiple values of a single field using
excluded_unless
andrequired_unless
the syntax seems to result in different expectations.See the code sample for a better explanation.
Code sample, to showcase or reproduce:
In this first example, using
excluded_unless
, all 3 written scenarios throw an error.In this second example, using
required_unless
, onlytestC
throws an error.I would expect that either both scenarios would throw errors with all scenarios, or the
excluded_unless
behaves similarly to the latter, in that onlyTestC
should throw errors.Suggested Proposal
First, I think we should update the implementations to have similar behavior. Secondly, I think the documentation in general lacks instruction for validating multiple values for a single field. Perhaps the answer is to simply use the OR operator
|
and redeclare the validation tag, but either way it should be documented.https://github.com/go-playground/validator/pull/1307/files
The text was updated successfully, but these errors were encountered: