Closed
Description
Description
I would like to request a new way to handle when a constraint should be applied or not by adding a new condition
option on all constraints.
The new condition
option should accept an expression in the same way as the Expression
constraint.
Thanks to this option, we should be able to use a more appropriated constraint than the Expression
constraint when possible.
Example
For example, it's easier to understand what a NotNull
constraint is intended to.
Instead of doing:
/**
* @Assert\Expression("value or this.isNullable()", message="This value should be null.")
*/
protected $nullableOnCondition;
We will be able to do:
/**
* @Assert\NotNull(condition="!this.isNullable()")
*/
protected $nullableOnCondition;