-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
kzorluoglu
wants to merge
2
commits into
symfony:7.4
Choose a base branch
from
kzorluoglu:validator-constraints-attribute-phpdoc-improve
base: 7.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,66 +12,44 @@ | |
namespace Symfony\Component\Validator\Constraints; | ||
|
||
/** | ||
* A sequence of validation groups. | ||
* The GroupSequence class represents a sequence of validation groups. | ||
* It is used to enforce a specific order in which validation groups should be processed. | ||
* | ||
* When validating a group sequence, each group will only be validated if all | ||
* of the previous groups in the sequence succeeded. For example: | ||
* When validating a group sequence, each group is validated sequentially. A group is only validated if all | ||
* 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. | ||
* | ||
* $validator->validate($address, null, new GroupSequence(['Basic', 'Strict'])); | ||
* 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. | ||
* | ||
* In the first step, all constraints that belong to the group "Basic" will be | ||
* validated. If none of the constraints fail, the validator will then validate | ||
* the constraints in group "Strict". This is useful, for example, if "Strict" | ||
* contains expensive checks that require a lot of CPU or slow, external | ||
* services. You usually don't want to run expensive checks if any of the cheap | ||
* checks fail. | ||
* | ||
* When adding metadata to a class, you can override the "Default" group of | ||
* that class with a group sequence: | ||
* #[GroupSequence(['Address', 'Strict'])] | ||
* class Address | ||
* { | ||
* // ... | ||
* } | ||
* | ||
* Whenever you validate that object in the "Default" group, the group sequence | ||
* will be validated: | ||
* | ||
* $validator->validate($address); | ||
* | ||
* If you want to execute the constraints of the "Default" group for a class | ||
* with an overridden default group, pass the class name as group name instead: | ||
* | ||
* $validator->validate($address, null, "Address") | ||
* This feature allows for fine-grained control over the validation process, ensuring efficient and effective | ||
* validation flows. | ||
* | ||
* @author Bernhard Schussek <bschussek@gmail.com> | ||
*/ | ||
#[\Attribute(\Attribute::TARGET_CLASS)] | ||
class GroupSequence | ||
{ | ||
/** | ||
* The groups in the sequence. | ||
* An array of groups that make up the sequence. The validation process will adhere to this order. | ||
* Each element can be a string representing a single group, an array of groups, or another GroupSequence. | ||
* | ||
* @var array<int, string|string[]|GroupSequence> | ||
*/ | ||
public array $groups; | ||
|
||
/** | ||
* The group in which cascaded objects are validated when validating | ||
* this sequence. | ||
* | ||
* By default, cascaded objects are validated in each of the groups of | ||
* the sequence. | ||
* Specifies the group that will be used for cascaded validation. | ||
* By default, all groups in the sequence are used for cascading. | ||
* If a group sequence is attached to a class, replacing the "Default" group, | ||
* this property allows specifying an alternate group for cascading validations. | ||
* | ||
* If a class has a group sequence attached, that sequence replaces the | ||
* "Default" group. When validating that class in the "Default" group, the | ||
* group sequence is used instead, but still the "Default" group should be | ||
* cascaded to other objects. | ||
* @var string|GroupSequence | ||
Comment on lines
68
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two lines should be deleted to make the fabbot happy. |
||
*/ | ||
public string|GroupSequence $cascadedGroup; | ||
|
||
/** | ||
* Creates a new group sequence. | ||
* Constructs a new GroupSequence with the specified sequence of groups. | ||
* | ||
* @param array<string|string[]|GroupSequence> $groups The groups in the sequence | ||
*/ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.