diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index a2635309f057b..c97d8a6880e55 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -68,6 +68,7 @@ public function validate($value, Constraint $constraint) if (!\in_array($_value, $choices, true)) { $this->context->buildViolation($constraint->multipleMessage) ->setParameter('{{ value }}', $this->formatValue($_value)) + ->setParameter('{{ choices }}', $this->formatValues($choices)) ->setCode(Choice::NO_SUCH_CHOICE_ERROR) ->setInvalidValue($_value) ->addViolation(); @@ -100,6 +101,7 @@ public function validate($value, Constraint $constraint) } elseif (!\in_array($value, $choices, true)) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) + ->setParameter('{{ choices }}', $this->formatValues($choices)) ->setCode(Choice::NO_SUCH_CHOICE_ERROR) ->addViolation(); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php index f9db12200e6d5..0235408af07c7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php @@ -169,6 +169,7 @@ public function testInvalidChoice() $this->buildViolation('myMessage') ->setParameter('{{ value }}', '"baz"') + ->setParameter('{{ choices }}', '"foo", "bar"') ->setCode(Choice::NO_SUCH_CHOICE_ERROR) ->assertRaised(); } @@ -186,6 +187,7 @@ public function testInvalidChoiceEmptyChoices() $this->buildViolation('myMessage') ->setParameter('{{ value }}', '"baz"') + ->setParameter('{{ choices }}', '') ->setCode(Choice::NO_SUCH_CHOICE_ERROR) ->assertRaised(); } @@ -202,6 +204,7 @@ public function testInvalidChoiceMultiple() $this->buildViolation('myMessage') ->setParameter('{{ value }}', '"baz"') + ->setParameter('{{ choices }}', '"foo", "bar"') ->setInvalidValue('baz') ->setCode(Choice::NO_SUCH_CHOICE_ERROR) ->assertRaised(); @@ -275,6 +278,7 @@ public function testStrictDisallowsDifferentType() $this->buildViolation('myMessage') ->setParameter('{{ value }}', '"2"') + ->setParameter('{{ choices }}', '1, 2') ->setCode(Choice::NO_SUCH_CHOICE_ERROR) ->assertRaised(); } @@ -291,6 +295,7 @@ public function testStrictWithMultipleChoices() $this->buildViolation('myMessage') ->setParameter('{{ value }}', '"3"') + ->setParameter('{{ choices }}', '1, 2, 3') ->setInvalidValue('3') ->setCode(Choice::NO_SUCH_CHOICE_ERROR) ->assertRaised(); 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