Description
Following my (unanswered) question at StackOverflow I'm reporting this as a bug, as no one seems to know the answer.
Currently there's no way that I can see to populate the code
property for the ConstraintViolation
class, as it is not defined in the Constraint
class. But as I see, it goes farther than that, as all the validators just ignore the parameters for the addViolation
method, making it impossible for simple asserts to define a code for the violation.
What I expect it to allow is the following:
/**
* @Assert\NotBlank(code=400)
* @Assert\Email(code=401)
*/
protected $email;
Problem is, the current validators call addViolations
without setting the 5th argument (code
). Plus, the Constraint
class doesn't implement such a code
property as mentioned.
If this is indeed considered a bug, I would like to send a PR with a patch, provided that this is the way that it should be working.If it's not, some directions would be amazing!