LessThanValidator.php 806 B

12345678910111213141516171819202122232425262728293031323334353637
  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. /**
  12. * Validates values are less than the previous (<).
  13. *
  14. * @author Daniel Holmes <daniel@danielholmes.org>
  15. * @author Bernhard Schussek <bschussek@gmail.com>
  16. */
  17. class LessThanValidator extends AbstractComparisonValidator
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. protected function compareValues($value1, $value2)
  23. {
  24. return null === $value2 || $value1 < $value2;
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. protected function getErrorCode()
  30. {
  31. return LessThan::TOO_HIGH_ERROR;
  32. }
  33. }