feature #12005 [Validator] Added "payload" option to all constraints 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
This commit is contained in:
commit
71b8c396a1
@ -13,6 +13,7 @@ CHANGELOG
|
|||||||
* deprecated `ClassMetadata::getMemberMetadatas()`
|
* deprecated `ClassMetadata::getMemberMetadatas()`
|
||||||
* deprecated `ClassMetadata::addMemberMetadata()`
|
* deprecated `ClassMetadata::addMemberMetadata()`
|
||||||
* [BC BREAK] added `Mapping\MetadataInterface::getConstraints()`
|
* [BC BREAK] added `Mapping\MetadataInterface::getConstraints()`
|
||||||
|
* added generic "payload" option to all constraints for attaching domain-specific data
|
||||||
|
|
||||||
2.5.0
|
2.5.0
|
||||||
-----
|
-----
|
||||||
|
@ -50,6 +50,12 @@ abstract class Constraint
|
|||||||
*/
|
*/
|
||||||
const PROPERTY_CONSTRAINT = 'property';
|
const PROPERTY_CONSTRAINT = 'property';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Domain-specific data attached to a constraint
|
||||||
|
* @var mixed
|
||||||
|
*/
|
||||||
|
public $payload;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the constraint with options.
|
* Initializes the constraint with options.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user