Skip to content

[Validator] Add error code to constraints #10413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andyj8 opened this issue Mar 11, 2014 · 3 comments
Closed

[Validator] Add error code to constraints #10413

andyj8 opened this issue Mar 11, 2014 · 3 comments

Comments

@andyj8
Copy link

andyj8 commented Mar 11, 2014

Seems to me that most APIs will assign unique error codes to each potential validation error, in addition to human-readable messages.

Before considering a PR, I wonder what the consensus on adding the ability to add a 'code' property to each field constraint would be?

@aeoris
Copy link
Contributor

aeoris commented Mar 11, 2014

I sent a PR some time ago (#7276), it may solve your issue. 😃

It's been a while since it had any activity at all, though.

@andyj8
Copy link
Author

andyj8 commented Mar 11, 2014

Once I realised that ConstraintViolation already accepts $code as the eighth param I did consider doing this same thing but don't really want to maintain duplicates of the validators.

For now I will use the constraint message as an internal code, and map it to an external code and message.

+1 for your PR.

@webmozart
Copy link
Contributor

Hi @andyj8, thank you for reporting this ticket! This is a duplicate of #7273. As of #11657 (2.6), it is possible to call getConstraint() on the ConstraintViolation object. We're discussing whether to add additional codes in #7273. Join the discussion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants