public function AbstractComparisonValidator::validate

Checks if the passed value is valid.

@api

Parameters

mixed $value The value that should be validated:

Constraint $constraint The constraint for the validation:

Overrides ConstraintValidatorInterface::validate

File

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php, line 27

Class

AbstractComparisonValidator
Provides a base class for the validation of property comparisons.

Namespace

Symfony\Component\Validator\Constraints

Code

public function validate($value, Constraint $constraint) {
  if (!$this
    ->compareValues($value, $constraint->value, $constraint)) {
    $this->context
      ->addViolation($constraint->message, array(
      '{{ value }}' => $this
        ->valueToString($constraint->value),
      '{{ compared_value }}' => $this
        ->valueToString($constraint->value),
      '{{ compared_value_type }}' => $this
        ->valueToType($constraint->value),
    ));
  }
}