[Validator] Added "payload" option to all constraints for attaching domain-specific data#12005
[Validator] Added "payload" option to all constraints for attaching domain-specific data#12005fabpot merged 1 commit intosymfony:masterfrom
Conversation
…omain-specific data
|
@webmozart given that you closed/replaced the PR I made (#7276) over a year and half ago after 6+ months on revision, would you mind answering me one question? How could I use this new PR to assign a code to a ConstraintViolation? The problem still exists imho, as you can't use the |
|
@aeoris You shouldn't. The |
|
@aeoris In fact, your PR contained two different things:
The first point is solved by the generic "payload" property. The second point is partially solved by the new I'll reapply your PR so that we can merge the interesting parts of it. :) Thanks again for your work! |
|
This needs to be covered by some tests (to ensure that all mapping loaders are supporting it properly for instance). |
|
@stof Sure? Isn't passing options to constraints covered sufficiently already? |
|
hmm, yeah, indeed. |
|
The test fail is unrelated. ping @symfony/deciders |
|
👍 |
1 similar comment
|
👍 |
|
Thank you @webmozart. |
…for attaching domain-specific data (webmozart) This PR was merged into the 2.6-dev branch. Discussion ---------- [Validator] Added "payload" option to all constraints for attaching domain-specific data | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7273 | License | MIT | Doc PR | TODO The "payload" option can be used to pass whatever data should be attached to a constraint for an application: ```php /** * Domain-specific error codes * @NotNull(payload="100") */ /** * Structured domain-specific data * @NotNull(payload={"display": "inline", "highlight": false}) */ ``` The term "payload" is borrowed from JSR-303. Commits ------- e8b7c6d [Validator] Added "payload" option to all constraints for attaching domain-specific data
…d option (xabbuh) This PR was merged into the 2.6 branch. Discussion ---------- [Reference][Constraints] document the validation payload option | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes (symfony/symfony#12005) | Applies to | 2.6+ | Fixed tickets | #4274 Commits ------- dca4655 document the validation payload option
The "payload" option can be used to pass whatever data should be attached to a constraint for an application:
The term "payload" is borrowed from JSR-303.