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

Skip to content

[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

Merged

Conversation

henry2778
Copy link
Contributor

Q A
Branch? 5.x
Bug fix? no
New feature? yes
Deprecations? no
Tickets #37451
License MIT
Doc PR todo

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

@nicolas-grekas nicolas-grekas added this to the 5.x milestone Oct 12, 2020
@henry2778 henry2778 force-pushed the feature/unique-validator-normalizer-5.x branch from e4ed9f6 to 3205952 Compare October 18, 2020 19:39
Copy link
Member

@derrabus derrabus left a 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.

Copy link
Member

@derrabus derrabus left a 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
Copy link
Member

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.

@fabpot
Copy link
Member

fabpot commented Mar 17, 2021

@henry2778 Can you have a look at the failing tests? It seems related to the changes here. Thank you.

@henry2778
Copy link
Contributor Author

@henry2778 Can you have a look at the failing tests? It seems related to the changes here. Thank you.

thanks! fixed

@derrabus derrabus changed the title [Validator] Add valueNormalizer option to Unique Constraint [Validator] Add normalizer option to Unique constraint Mar 17, 2021
@derrabus derrabus force-pushed the feature/unique-validator-normalizer-5.x branch from 51c36bf to 44e1e8b Compare March 18, 2021 14:44
@derrabus
Copy link
Member

Thank you @henry2778.

@derrabus derrabus merged commit 1c22e6a into symfony:5.x Mar 18, 2021
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Mar 27, 2021
…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
@fabpot fabpot mentioned this pull request Apr 18, 2021
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