-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Validator] Add the match option to the Choice constraint #45977
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
Conversation
| * Deprecate constraint `ExpressionLanguageSyntax`, use `ExpressionSyntax` instead | ||
| * Add method `__toString()` to `ConstraintViolationInterface` & `ConstraintViolationListInterface` | ||
| * Allow creating constraints with required arguments | ||
| * Add the `match` option to the `Choice` constraint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to read the description of the PR to get what this was for.
Maybe it's a naming issue? Would negate be better instead? I'm not sure, just trying :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another possible naming is shouldMatch, as it's more clear to understand that a boolean is expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've spent some time thinking about this. I didn't find any reasonable alternative. The whole concept seems like an edge case anyway, so let's keep match (at least, this is the same name as for Regexp). Doc should be well written though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And of course, if anyone has a better name before 6.2 final, we will be able to change it quickly.
cc @symfony/mergers
|
Thank you @fancyweb. |
I'd like to add a
matchoption like the one in theRegexconstraint to validate that a value is not in a given set of choices.Reusing the
Choiceconstraint with a flag instead of creating theNotChoiceconstraint looks way better to me.