8000 [Validator] Add PHPDoc to `GroupSequence` attribute class and properties by kzorluoglu · Pull Request #53428 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Add PHPDoc to GroupSequence attribute class and properties #53428

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 7.4
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
GroupSequence class description with example extend
  • Loading branch information
Koray Zorluoglu committed Jan 5, 2024
commit 3a19f10b32899123af9f524264fbf0f952d3682e
26 changes: 24 additions & 2 deletions src/Symfony/Component/Validator/Constraints/GroupSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,30 @@
* previous groups in the sequence succeeded. This approach is beneficial for scenarios where certain validation
* groups are more resource-intensive or rely on the success of prior validations.
*
* Group sequences can also be used to override the "Default" validation group for a class. When a class has an
* associated group sequence and is validated in the "Default" group, the group sequence is applied instead.
* For example, when validating an address:
*
* $validator->validate($address, null, new GroupSequence(['Basic', 'Strict']));
*
* In this case, all constraints in the "Basic" group are validated first. If none of the "Basic" constraints fail,
* the "Strict" group constraints are then validated. This is useful if, for instance, the "Strict" group contains
* more resource-intensive checks.
*
* Group sequences can also be used to override the "Default" validation group for a class:
*
* #[GroupSequence(['Address', 'Strict'])]
* class Address
* {
* // ...
* }
*
* When you validate the `Address` object in the "Default" group, the specified group sequence is applied:
*
* $validator->validate($address);
*
* To validate the constraints of the "Default" group for a class with an overridden default group,
* pass the class name as the group name:
*
* $validator->validate($address, null, "Address")
*
* This feature allows for fine-grained control over the validation process, ensuring efficient and effective
* validation flows.
Expand Down
0