Merge remote branch 'weaverryan/validator_choice_message_changes'

* weaverryan/validator_choice_message_changes:
  [Validator] Modifying Choice message and adding a different multiple message
This commit is contained in:
Fabien Potencier 2011-04-22 08:40:08 +02:00
commit f626afcdef
2 changed files with 5 additions and 4 deletions

View File

@ -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}

View File

@ -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;
}