Drupal investigation

Range.php 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. use Symfony\Component\Validator\Exception\MissingOptionsException;
  13. /**
  14. * @Annotation
  15. * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
  16. *
  17. * @author Bernhard Schussek <bschussek@gmail.com>
  18. */
  19. class Range extends Constraint
  20. {
  21. const INVALID_CHARACTERS_ERROR = 'ad9a9798-7a99-4df7-8ce9-46e416a1e60b';
  22. const TOO_HIGH_ERROR = '2d28afcb-e32e-45fb-a815-01c431a86a69';
  23. const TOO_LOW_ERROR = '76454e69-502c-46c5-9643-f447d837c4d5';
  24. /**
  25. * @deprecated Deprecated since version 2.8, to be removed in 3.0. Use
  26. * {@link INVALID_CHARACTERS_ERROR} instead.
  27. */
  28. const INVALID_VALUE_ERROR = self::INVALID_CHARACTERS_ERROR;
  29. /**
  30. * @deprecated Deprecated since version 2.8, to be removed in 3.0. Use
  31. * {@link TOO_HIGH_ERROR} instead.
  32. */
  33. const BEYOND_RANGE_ERROR = self::TOO_HIGH_ERROR;
  34. /**
  35. * @deprecated Deprecated since version 2.8, to be removed in 3.0. Use
  36. * {@link TOO_LOW_ERROR} instead.
  37. */
  38. const BELOW_RANGE_ERROR = self::TOO_LOW_ERROR;
  39. protected static $errorNames = array(
  40. self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR',
  41. self::TOO_HIGH_ERROR => 'TOO_HIGH_ERROR',
  42. self::TOO_LOW_ERROR => 'TOO_LOW_ERROR',
  43. );
  44. public $minMessage = 'This value should be {{ limit }} or more.';
  45. public $maxMessage = 'This value should be {{ limit }} or less.';
  46. public $invalidMessage = 'This value should be a valid number.';
  47. public $min;
  48. public $max;
  49. public function __construct($options = null)
  50. {
  51. parent::__construct($options);
  52. if (null === $this->min && null === $this->max) {
  53. throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s', __CLASS__), array('min', 'max'));
  54. }
  55. }
  56. }