Choice.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Validator\Constraints;
  11. use Symfony\Component\Validator\Constraint;
  12. /**
  13. * @Annotation
  14. * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
  15. *
  16. * @author Bernhard Schussek <bschussek@gmail.com>
  17. */
  18. class Choice extends Constraint
  19. {
  20. const NO_SUCH_CHOICE_ERROR = '8e179f1b-97aa-4560-a02f-2a8b42e49df7';
  21. const TOO_FEW_ERROR = '11edd7eb-5872-4b6e-9f12-89923999fd0e';
  22. const TOO_MANY_ERROR = '9bd98e49-211c-433f-8630-fd1c2d0f08c3';
  23. protected static $errorNames = array(
  24. self::NO_SUCH_CHOICE_ERROR => 'NO_SUCH_CHOICE_ERROR',
  25. self::TOO_FEW_ERROR => 'TOO_FEW_ERROR',
  26. self::TOO_MANY_ERROR => 'TOO_MANY_ERROR',
  27. );
  28. public $choices;
  29. public $callback;
  30. public $multiple = false;
  31. public $strict = false;
  32. public $min;
  33. public $max;
  34. public $message = 'The value you selected is not a valid choice.';
  35. public $multipleMessage = 'One or more of the given values is invalid.';
  36. public $minMessage = 'You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices.';
  37. public $maxMessage = 'You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices.';
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function getDefaultOption()
  42. {
  43. return 'choices';
  44. }
  45. }