Skip to content

Commit 9de3680

Browse files
committed
[Validator] Fix fields without constraints in Collection
1 parent 89b3d63 commit 9de3680

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ private static function isFieldsOption($options): bool
103103
return true;
104104
}
105105

106+
if (null === $optionOrField) {
107+
return true;
108+
}
109+
106110
if (!\is_array($optionOrField)) {
107111
return false;
108112
}

src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,15 @@ public function testEmptyFieldsInOptions()
175175
$this->assertSame('foo bar baz', $constraint->extraFieldsMessage);
176176
}
177177

178-
public function testEmptyConstraintListFor()
178+
/**
179+
* @testWith [[]]
180+
* [null]
181+
*/
182+
public function testEmptyConstraintListForField(?array $fieldConstraint)
179183
{
180-
$constraint = new Collection([
181-
'foo' => [],
184+
$constraint = new Collection(
185+
[
186+
'foo' => $fieldConstraint,
182187
],
183188
null,
184189
null,
@@ -193,11 +198,15 @@ public function testEmptyConstraintListFor()
193198
$this->assertSame('foo bar baz', $constraint->extraFieldsMessage);
194199
}
195200

196-
public function testEmptyConstraintListForFieldInOptions()
201+
/**
202+
* @testWith [[]]
203+
* [null]
204+
*/
205+
public function testEmptyConstraintListForFieldInOptions(?array $fieldConstraint)
197206
{
198207
$constraint = new Collection([
199208
'fields' => [
200-
'foo' => [],
209+
'foo' => $fieldConstraint,
201210
],
202211
'allowExtraFields' => true,
203212
'extraFieldsMessage' => 'foo bar baz',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy