From 18566015242b0ee9d4db85f577d0f35ce5b60e1f Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 21 Apr 2011 20:05:13 -0500 Subject: [PATCH] [Validator] Modifying Choice message and adding a different multiple message --- src/Symfony/Component/Validator/Constraints/Choice.php | 7 ++++--- .../Component/Validator/Constraints/ChoiceValidator.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/Choice.php b/src/Symfony/Component/Validator/Constraints/Choice.php index 6656118bf1..ba666d6519 100644 --- a/src/Symfony/Component/Validator/Constraints/Choice.php +++ b/src/Symfony/Component/Validator/Constraints/Choice.php @@ -18,9 +18,10 @@ class Choice extends \Symfony\Component\Validator\Constraint public $multiple = false; public $min = null; public $max = null; - public $message = 'This value should be one of the given choices'; - public $minMessage = 'You should select at least {{ limit }} choices'; - public $maxMessage = 'You should select at most {{ limit }} choices'; + public $message = 'The value you selected is not a valid choice'; + public $multipleMessage = 'One or more of the given values is invalid'; + public $minMessage = 'You must select at least {{ limit }} choices'; + public $maxMessage = 'You must select at most {{ limit }} choices'; /** * {@inheritDoc} diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index 58f2db7dc3..5c195dc38f 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -54,7 +54,7 @@ class ChoiceValidator extends ConstraintValidator if ($constraint->multiple) { foreach ($value as $_value) { if (!in_array($_value, $choices, true)) { - $this->setMessage($constraint->message, array('{{ value }}' => $_value)); + $this->setMessage($constraint->multipleMessage, array('{{ value }}' => $_value)); return false; }