AbstractComparison.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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\ConstraintDefinitionException;
  13. /**
  14. * Used for the comparison of values.
  15. *
  16. * @author Daniel Holmes <daniel@danielholmes.org>
  17. * @author Bernhard Schussek <bschussek@gmail.com>
  18. */
  19. abstract class AbstractComparison extends Constraint
  20. {
  21. public $message;
  22. public $value;
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function __construct($options = null)
  27. {
  28. if (is_array($options) && !isset($options['value'])) {
  29. throw new ConstraintDefinitionException(sprintf(
  30. 'The %s constraint requires the "value" option to be set.',
  31. get_class($this)
  32. ));
  33. }
  34. parent::__construct($options);
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function getDefaultOption()
  40. {
  41. return 'value';
  42. }
  43. }