|
19 | 19 | * previous groups in the sequence succeeded. This approach is beneficial for scenarios where certain validation
|
20 | 20 | * groups are more resource-intensive or rely on the success of prior validations.
|
21 | 21 | *
|
22 |
| - * Group sequences can also be used to override the "Default" validation group for a class. When a class has an |
23 |
| - * associated group sequence and is validated in the "Default" group, the group sequence is applied instead. |
| 22 | + * For example, when validating an address: |
| 23 | + * |
| 24 | + * $validator->validate($address, null, new GroupSequence(['Basic', 'Strict'])); |
| 25 | + * |
| 26 | + * In this case, all constraints in the "Basic" group are validated first. If none of the "Basic" constraints fail, |
| 27 | + * the "Strict" group constraints are then validated. This is useful if, for instance, the "Strict" group contains |
| 28 | + * more resource-intensive checks. |
| 29 | + * |
| 30 | + * Group sequences can also be used to override the "Default" validation group for a class: |
| 31 | + * |
| 32 | + * #[GroupSequence(['Address', 'Strict'])] |
| 33 | + * class Address |
| 34 | + * { |
| 35 | + * // ... |
| 36 | + * } |
| 37 | + * |
| 38 | + * When you validate the `Address` object in the "Default" group, the specified group sequence is applied: |
| 39 | + * |
| 40 | + * $validator->validate($address); |
| 41 | + * |
| 42 | + * To validate the constraints of the "Default" group for a class with an overridden default group, |
| 43 | + * pass the class name as the group name: |
| 44 | + * |
| 45 | + * $validator->validate($address, null, "Address") |
24 | 46 | *
|
25 | 47 | * This feature allows for fine-grained control over the validation process, ensuring efficient and effective
|
26 | 48 | * validation flows.
|
|
0 commit comments