Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 1 commit into from
Jul 21, 2022

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Apr 8, 2022

Q A
Branch? 6.1
Bug fix? no
New feature? yes
Deprecations? no
Tickets #26074
License MIT
Doc PR -

I'd like to add a match option like the one in the Regex constraint to validate that a value is not in a given set of choices.

Reusing the Choice constraint with a flag instead of creating the NotChoice constraint looks way better to me.

@@ -8,6 +8,7 @@ CHANGELOG
* 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
Copy link
Member

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 :)

Copy link
Member

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.

Copy link
Member

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 :)

Copy link
Member

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

@fancyweb fancyweb modified the milestones: 6.1, 6.2 Apr 26, 2022
@fabpot
Copy link
Member

fabpot commented Jul 21, 2022

Thank you @fancyweb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants