-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Expression validator now processes null values #11709
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
This must be documented in the component changelog for 2.6 (prefixed with |
I don't understand the reasoning: it cannot be merged without the changelog update requested |
Well, the discussion in the previous PR already indicate that we agreed abotu merging such change in master (the reason the PR was replaced is that we rejected changing this behavior in 2.4). IMO, the only thing missing to make it mergeable is precisely the changelog update |
The ExpressionValidator was incorrectly skipping validation of null or empty string values.
cbade6b
to
580e1a7
Compare
👍 |
1 similar comment
👍 |
Thank you @tommygnr. |
…lues (tommygnr) This PR was merged into the 2.6-dev branch. Discussion ---------- [Validator] Expression validator now processes null values | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | yes(minor) | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | The ExpressionValidator was incorrectly skipping validation of null or empty string values. For example the following was (incorrectly) considered valid if hairColour is null because the validator was skipped ```php <?php namespace Acme\DemoBundle\Model\Person; use Symfony\Component\Validator\Constraints as Assert; class Person { private $hasHair; /** * @Assert\Expression( * "!(this.hasHair() and value == null)", * message="If you have hair you must pick its colour!" * ) */ private $hairColour; } ``` This is a follow on from #11590 but is targeted against master as the BC break introduced was considered undesirable for currently released versions of symfony. I will squash and create a documentation PR once there is consensus that this is ready to be merged. Commits ------- 580e1a7 [Validator] fixed: Expressions always valid for null values
…nstraint in 2.6) (xabbuh) This PR was merged into the master branch. Discussion ---------- [Reference][Constraints] validate `null` (Expression constraint in 2.6) | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes (symfony/symfony#11709) | Applies to | 2.6 | Fixed tickets | master part of #4191 Since Symfony 2.6, the Expression constraint doesn't skip validating `null` values. Probably, it's a good idea to merge #4202 first and rebase this then to avoid merge conflicts. Commits ------- fb18056 validate `null` (Expression constraint in 2.6)
👍 |
The ExpressionValidator was incorrectly skipping validation of null or empty string values.
For example the following was (incorrectly) considered valid if hairColour is null because the validator was skipped
This is a follow on from #11590 but is targeted against master as the BC break introduced was considered undesirable for currently released versions of symfony.
I will squash and create a documentation PR once there is consensus that this is ready to be merged.