Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Validator] Code property can't be populated to ConstraintViolation#7276
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
aeoris commentedMar 5, 2013
| Q | A |
|---|---|
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #7273,#9691 |
| License | MIT |
| Doc PR | symfony/symfony-docs#2302 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Take a look atcontext->addViolation(), I think passing null as the 3rd argument is not equivalent to what was done before, there's a gotcha in the method !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Oh! You mean passing$value instead? If so, please tell me and I will change all of them to consider that! Did you detect any other issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yep this is what I mean (and you should add a unit test for that)
No other issue detected but I only quickly scanned it.
aeoris commentedMar 12, 2013
Ping@vicb Did my last couple commits solve the issue you pointed out? |
vicb commentedMar 13, 2013
Looks good. "Diego Agulló"notifications@github.com wrote:
|
aeoris commentedMar 13, 2013
Done! I just don't know whether this is a new feature or a bug fix, so I selected both and made a PR to symfony-docs as well. |
stof commentedMar 19, 2013
you are adding a way to configure the code in the constraint. This is a new feature. I updated the description accordingly |
fabpot commentedSep 13, 2013
ping @bschussek |
webmozart commentedSep 16, 2013
aeoris commentedNov 2, 2013
@bschussek Haven't forgot this issue, and I'm happy to say that I finally have time enough to give it a go. I'm on it! |
…onCodeConflicts:src/Symfony/Component/Validator/Constraints/CountryValidator.phpsrc/Symfony/Component/Validator/Constraints/LanguageValidator.phpsrc/Symfony/Component/Validator/Constraints/LocaleValidator.phpsrc/Symfony/Component/Validator/Constraints/MaxLengthValidator.phpsrc/Symfony/Component/Validator/Constraints/MaxValidator.phpsrc/Symfony/Component/Validator/Constraints/MinLengthValidator.phpsrc/Symfony/Component/Validator/Constraints/MinValidator.php
aeoris commentedNov 8, 2013
@bschussek can you please check whether this PR matches#7273 now? Thanks! |
cordoval commentedDec 6, 2013
aeoris commentedDec 6, 2013
@cordoval done, thanks! |
cordoval commentedDec 21, 2013
👍 just make sure you have not missed testing each of those codes i guess? also how are you generating the codes, so that in future additions is clear how you are generating those codes. Thanks. |
aeoris commentedDec 23, 2013
@cordoval I'll double check the tests as soon as I get back home next Monday. The codes are RFC 4122-compliant 128 bit random values as proposed here by @bschussek:#7273 (comment) |
aeoris commentedFeb 15, 2014
@cordoval I did indeed miss three code checks, but those are fixed now. |
stloyd commentedMar 11, 2014
@fabpot@webmozart Could you have a look at this? |
aeoris commentedMay 23, 2014
@webmozart any progress on this? |
… (webmozart)This PR was merged into the 2.6-dev branch.Discussion----------[Validator] Added ConstraintViolation::getConstraint()| Q | A| ------------- | ---| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#5050| License | MIT| Doc PR | -This PR adds a `getConstraint()` method to the `ConstraintViolation` in order to access the constraint causing the violation.Related to#7276,#7273 and#9691.Commits-------ce1d209 [Validator] Added ConstraintViolation::getConstraint()
webmozart commentedSep 23, 2014
Replaced by#12005. |
This PR was merged into the 2.3 branch.Discussion----------[Validator] Simplified testing of violations| Q | A| ------------- | ---| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | -| License | MIT| Doc PR | -I simplified the assertion of violations in preparation of a replacement PR for#7276.Commits-------8e5537b [Validator] Simplified testing of violations
…multiple error causes (webmozart)This PR was merged into the 2.6-dev branch.Discussion----------[Validator] Added error codes to all constraints with multiple error causes| Q | A| ------------- | ---| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#7276| License | MIT| Doc PR | TODOThis PR depends on#12015 and#12016 being merged first. However, a few changes in52cb7df first must be backported to#12016.This PR introduces error codes for all constraints with multiple error paths. This lets you determine what exactly the reason was that a constraint failed:```php$validator = Validation::createValidator();$violations = $validator->validate('0-4X19-92619812', new Isbn());foreach ($violations as $violation) { var_dump($violation->getCode()); // => int(3) var_dump(Isbn::getErrorName($violation->getCode())); // => string(24) "ERROR_INVALID_CHARACTERS" var_dump($violation->getConstraint()->getErrorName($violation->getCode())); // => string(24) "ERROR_INVALID_CHARACTERS"}```The `getErrorName()` method is especially helpful for REST APIs, where you can return both an error code and a description of that error now.**Todos**- [x] Backport a few structural changes to#12016- [x] Update constraints outside of the Validator component- [x] Rebase on master (after merging#12015 and#12016)Commits-------3b50bf2 [Validator] Added error codes to all constraints with multiple error causes