Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add a way to unique identity a validation error #7568

Closed
alex88 opened this Issue · 3 comments

3 participants

Alessandro Tagliapietra Christophe Coevoet Bernhard Schussek
Alessandro Tagliapietra

It would be nice in my opinion to be able from the validator errors to know what kind of assertion has been done to generate that error.

For example, we've inserted to the User entity an email field with value 'somebadvalue'. If we're displaying a form that's ok since it automatically shows the error in the right place and the user knows about it.

But if we manually validate the User entity, using the validation service, we've just a bunch of errors that doesn't let us know which kind of assertion has been done in an unique way.

We can just match the message but it's easy to be wrong checking only that. It would be nice to add the assertion object or at least the assertion class name, what you guys think?

Christophe Coevoet
Collaborator

The ConstraintViolation returned by the validator contains the propertyPath where the violation happens: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/ConstraintViolation.php#L49

Note that this is how the form error can be mapped to the right field

Alessandro Tagliapietra

It will just let you know which field has errors, not which assertion failed

Bernhard Schussek
Collaborator

Thank you for reporting this issue! This seems to be a duplicate of #7273.

Bernhard Schussek webmozart closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.