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: use Symfony\Component\Validator\Exception\MissingOptionsException; 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 Range extends Constraint Chris@0: { Chris@0: const INVALID_CHARACTERS_ERROR = 'ad9a9798-7a99-4df7-8ce9-46e416a1e60b'; Chris@0: const TOO_HIGH_ERROR = '2d28afcb-e32e-45fb-a815-01c431a86a69'; Chris@0: const TOO_LOW_ERROR = '76454e69-502c-46c5-9643-f447d837c4d5'; Chris@0: Chris@17: protected static $errorNames = [ Chris@0: self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', Chris@0: self::TOO_HIGH_ERROR => 'TOO_HIGH_ERROR', Chris@0: self::TOO_LOW_ERROR => 'TOO_LOW_ERROR', Chris@17: ]; Chris@0: Chris@0: public $minMessage = 'This value should be {{ limit }} or more.'; Chris@0: public $maxMessage = 'This value should be {{ limit }} or less.'; Chris@0: public $invalidMessage = 'This value should be a valid number.'; Chris@0: public $min; Chris@0: public $max; Chris@0: Chris@0: public function __construct($options = null) Chris@0: { Chris@0: parent::__construct($options); Chris@0: Chris@0: if (null === $this->min && null === $this->max) { Chris@17: throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s', __CLASS__), ['min', 'max']); Chris@0: } Chris@0: } Chris@0: }