Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. WhenValidator.php

function WhenValidator::validate

Overrides ConstraintValidatorInterface::validate

File

vendor/symfony/validator/Constraints/WhenValidator.php, line 26

Class

WhenValidator

Namespace

Symfony\Component\Validator\Constraints

Code

public function validate(mixed $value, Constraint $constraint) : void {
    if (!$constraint instanceof When) {
        throw new UnexpectedTypeException($constraint, When::class);
    }
    $context = $this->context;
    $variables = $constraint->values;
    $variables['value'] = $value;
    $variables['this'] = $context->getObject();
    $variables['context'] = $context;
    if ($this->getExpressionLanguage()
        ->evaluate($constraint->expression, $variables)) {
        $context->getValidator()
            ->inContext($context)
            ->validate($value, $constraint->constraints);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal