Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Validator\Constraints; Chris@0: Chris@0: use Symfony\Component\Validator\Constraint; Chris@0: Chris@0: /** Chris@0: * @Annotation Chris@0: * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) Chris@0: * Chris@0: * @author Bernhard Schussek Chris@0: */ Chris@0: class Choice extends Constraint Chris@0: { Chris@0: const NO_SUCH_CHOICE_ERROR = '8e179f1b-97aa-4560-a02f-2a8b42e49df7'; Chris@0: const TOO_FEW_ERROR = '11edd7eb-5872-4b6e-9f12-89923999fd0e'; Chris@0: const TOO_MANY_ERROR = '9bd98e49-211c-433f-8630-fd1c2d0f08c3'; Chris@0: Chris@17: protected static $errorNames = [ Chris@0: self::NO_SUCH_CHOICE_ERROR => 'NO_SUCH_CHOICE_ERROR', Chris@0: self::TOO_FEW_ERROR => 'TOO_FEW_ERROR', Chris@0: self::TOO_MANY_ERROR => 'TOO_MANY_ERROR', Chris@17: ]; Chris@0: Chris@0: public $choices; Chris@0: public $callback; Chris@0: public $multiple = false; Chris@0: public $strict = false; Chris@0: public $min; Chris@0: public $max; Chris@0: public $message = 'The value you selected is not a valid choice.'; Chris@0: public $multipleMessage = 'One or more of the given values is invalid.'; Chris@0: public $minMessage = 'You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices.'; Chris@0: public $maxMessage = 'You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices.'; Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getDefaultOption() Chris@0: { Chris@0: return 'choices'; Chris@0: } Chris@0: }