Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit71dfa35

Browse files
committed
add newchoices wildcard in message
1 parent5f737e8 commit71dfa35

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

‎src/Symfony/Component/Validator/Constraints/ChoiceValidator.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function validate($value, Constraint $constraint)
6868
if (!\in_array($_value,$choices,true)) {
6969
$this->context->buildViolation($constraint->multipleMessage)
7070
->setParameter('{{ value }}',$this->formatValue($_value))
71+
->setParameter('{{ choices }}',$this->formatValues($choices))
7172
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
7273
->setInvalidValue($_value)
7374
->addViolation();
@@ -100,6 +101,7 @@ public function validate($value, Constraint $constraint)
100101
}elseif (!\in_array($value,$choices,true)) {
101102
$this->context->buildViolation($constraint->message)
102103
->setParameter('{{ value }}',$this->formatValue($value))
104+
->setParameter('{{ choices }}',$this->formatValues($choices))
103105
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
104106
->addViolation();
105107
}

‎src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public function testInvalidChoice()
169169

170170
$this->buildViolation('myMessage')
171171
->setParameter('{{ value }}','"baz"')
172+
->setParameter('{{ choices }}','"foo", "bar"')
172173
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
173174
->assertRaised();
174175
}
@@ -186,6 +187,7 @@ public function testInvalidChoiceEmptyChoices()
186187

187188
$this->buildViolation('myMessage')
188189
->setParameter('{{ value }}','"baz"')
190+
->setParameter('{{ choices }}','')
189191
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
190192
->assertRaised();
191193
}
@@ -202,6 +204,7 @@ public function testInvalidChoiceMultiple()
202204

203205
$this->buildViolation('myMessage')
204206
->setParameter('{{ value }}','"baz"')
207+
->setParameter('{{ choices }}','"foo", "bar"')
205208
->setInvalidValue('baz')
206209
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
207210
->assertRaised();
@@ -275,6 +278,7 @@ public function testStrictDisallowsDifferentType()
275278

276279
$this->buildViolation('myMessage')
277280
->setParameter('{{ value }}','"2"')
281+
->setParameter('{{ choices }}','1, 2')
278282
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
279283
->assertRaised();
280284
}
@@ -291,6 +295,7 @@ public function testStrictWithMultipleChoices()
291295

292296
$this->buildViolation('myMessage')
293297
->setParameter('{{ value }}','"3"')
298+
->setParameter('{{ choices }}','1, 2, 3')
294299
->setInvalidValue('3')
295300
->setCode(Choice::NO_SUCH_CHOICE_ERROR)
296301
->assertRaised();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp