Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 31b609e

Browse files
committed
[Validator] Allow validating multiple groups in one GroupSequence step
1 parent 3847bad commit 31b609e

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/Symfony/Component/Validator/Constraints/GroupSequence.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GroupSequence
5757
/**
5858
* The groups in the sequence.
5959
*
60-
* @var string[]|GroupSequence[]
60+
* @var string[]|array[]|GroupSequence[]
6161
*/
6262
public $groups;
6363

src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,20 @@ public function getTestReplaceDefaultGroup()
12121212
'Violation in Group 2',
12131213
),
12141214
),
1215+
array(
1216+
'sequence' => new GroupSequence(array('Group 1', array('Group 2', 'Group 3'), 'Entity')),
1217+
'assertViolations' => array(
1218+
'Violation in Group 2',
1219+
'Violation in Group 3',
1220+
),
1221+
),
1222+
array(
1223+
'sequence' => array('Group 1', array('Group 2', 'Group 3'), 'Entity'),
1224+
'assertViolations' => array(
1225+
'Violation in Group 2',
1226+
'Violation in Group 3',
1227+
),
1228+
),
12151229
);
12161230
}
12171231
}

src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ private function stepThroughGroupSequence($value, $object, $cacheKey, MetadataIn
773773
$cascadedGroups = $cascadedGroup ? array($cascadedGroup) : null;
774774

775775
foreach ($groupSequence->groups as $groupInSequence) {
776-
$groups = array($groupInSequence);
776+
$groups = (array) $groupInSequence;
777777

778778
if ($metadata instanceof ClassMetadataInterface) {
779779
$this->validateClassNode(

0 commit comments

Comments
 (0)