Closed
Description
The issue #11586 could be solved by providing a valid()
method in the Expression constraint (as alias for $context->getValidator()->validate()
, but returning a boolean):
/**
* @Expression("valid(this.author) or valid(this.creator)", message="Author or creator must be valid!")
*/
Additionally, a "constraints" option could be added which allows to pass constraints that can be used within the expression:
/**
* @Expression(
* "valid(value, regex) or valid(value, threeOrMore)",
* message="Value must match regex or be greater than 3!",
* constraints={
* "regex" = @Regex("/here-is-my-regex/"),
* "threeOrMore" = @GreaterThan(3),
* }
* )
*/
Opinions?