symfony/symfony — pull request #11590 by tommygnr (2014-08-06 16:45:35+00:00)
Title: [Validator] fixed: Expressions always valid for null values

| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| 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
```
// src/Acme/DemoBundle/Model/Person.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;
}
```