-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Add normalizer option to Unique constraint #38488
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
[Validator] Add normalizer option to Unique constraint #38488
Conversation
e4ed9f6
to
3205952
Compare
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'm sorry nobody has picked up that PR yet. I think, this change could be a useful addition to the unique validator.
src/Symfony/Component/Validator/Constraints/UniqueValidator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Constraints/UniqueValidator.php
Outdated
Show resolved
Hide resolved
db37354
to
00b2a49
Compare
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.
Thanks a lot. We're almost good. 😃
@@ -16,6 +16,14 @@ | |||
use Symfony\Component\Validator\Exception\UnexpectedValueException; | |||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; | |||
|
|||
class CallableClass |
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.
Please declare the test case class first. This fixture class should be moved to the end of the file.
src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php
Outdated
Show resolved
Hide resolved
602ed32
to
03b91f7
Compare
@henry2778 Can you have a look at the failing tests? It seems related to the changes here. Thank you. |
thanks! fixed |
51c36bf
to
44e1e8b
Compare
Thank you @henry2778. |
…henry2778) This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- [Validator] Add normalizer option to Unique constraint Hello. Documenting the feature symfony/symfony#38488 about `normalizer` option for Unique constraint. 1. Updated the intro paragraph mentioning the strict comparison 2. Added normalizer to the option list 3. Added normalizer option description. There is a include file for that, but since the description is slightly different, I decided not use it. Thanks! Commits ------- 92072d9 [Validator] Add normalizer option to Unique constraint
Hello! Reopening my PR #37507 with target branch
5.x
This PR is about #37451. The idea is to make that constraint more flexible and able to process business rules, especially when working with objects. We can think about it as the similar feature in UniqueEntity constraint, when we declare on which attributes we are applying the constraint. But in our case it is more general - we pass a callable with whatever logic we want to apply to collection elements before we apply 'uniqueness check' :)
Looks like no BC breaks. Thanks! :)