Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #11709 [Validator] Expression validator now processes null va…
…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
- Loading branch information
Showing
4 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters