4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator\Constraints;
14 use Symfony\Component\PropertyAccess\PropertyAccess;
15 use Symfony\Component\Validator\Constraint;
16 use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
19 * Used for the comparison of values.
21 * @author Daniel Holmes <daniel@danielholmes.org>
22 * @author Bernhard Schussek <bschussek@gmail.com>
24 abstract class AbstractComparison extends Constraint
33 public function __construct($options = null)
35 if (null === $options) {
39 if (is_array($options)) {
40 if (!isset($options['value']) && !isset($options['propertyPath'])) {
41 throw new ConstraintDefinitionException(sprintf('The "%s" constraint requires either the "value" or "propertyPath" option to be set.', get_class($this)));
44 if (isset($options['value']) && isset($options['propertyPath'])) {
45 throw new ConstraintDefinitionException(sprintf('The "%s" constraint requires only one of the "value" or "propertyPath" options to be set, not both.', get_class($this)));
48 if (isset($options['propertyPath']) && !class_exists(PropertyAccess::class)) {
49 throw new ConstraintDefinitionException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "propertyPath" option.', get_class($this)));
53 parent::__construct($options);
59 public function getDefaultOption()