Skip to content

Commit

Permalink
feature #35815 [Validator] Allow Sequentially constraints on classes …
Browse files Browse the repository at this point in the history
…+ target guards (ogizanagi)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[Validator] Allow Sequentially constraints on classes + target guards

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | N/A <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | todo in symfony/symfony-docs#13206 if not merged yet

There is no reason to limit this constraint to properties, so let's add classes as targets.

Additionally, let's ensure embedded constraints matches allowed targets too.

Commits
-------

1e02a96 [Validator] Allow Sequentially constraints on classes
  • Loading branch information
nicolas-grekas committed Feb 25, 2020
2 parents d297231 + 1e02a96 commit 7b89d1b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Symfony/Component/Validator/Constraints/Sequentially.php
Expand Up @@ -16,7 +16,7 @@
* Validation for the nested constraints collection will stop at first violation.
*
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
* @Target({"CLASS", "PROPERTY", "METHOD", "ANNOTATION"})
*
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
*/
Expand All @@ -38,4 +38,9 @@ protected function getCompositeOption()
{
return 'constraints';
}

public function getTargets()
{
return [self::CLASS_CONSTRAINT, self::PROPERTY_CONSTRAINT];
}
}

0 comments on commit 7b89d1b

Please sign in to comment.