10000 [Validator] Code property can't be populated to ConstraintViolation · Issue #7273 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Validator] Code property can't be populated to ConstraintViolation #7273
Closed
@aeoris

Description

@aeoris

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0