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:
Fabien Potencier 2014-09-24 13:45:32 +02:00
commit 71b8c396a1
2 changed files with 7 additions and 0 deletions

View File

@ -13,6 +13,7 @@ CHANGELOG
* deprecated `ClassMetadata::getMemberMetadatas()`
* deprecated `ClassMetadata::addMemberMetadata()`
* [BC BREAK] added `Mapping\MetadataInterface::getConstraints()`
* added generic "payload" option to all constraints for attaching domain-specific data
2.5.0
-----

View File

@ -50,6 +50,12 @@ abstract class Constraint
*/
const PROPERTY_CONSTRAINT = 'property';
/**
* Domain-specific data attached to a constraint
* @var mixed
*/
public $payload;
/**
* Initializes the constraint with options.
*