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

Breadcrumb

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

function BlankValidator::validate

Overrides ConstraintValidatorInterface::validate

File

vendor/symfony/validator/Constraints/BlankValidator.php, line 23

Class

BlankValidator
@author Bernhard Schussek <bschussek@gmail.com>

Namespace

Symfony\Component\Validator\Constraints

Code

public function validate(mixed $value, Constraint $constraint) : void {
    if (!$constraint instanceof Blank) {
        throw new UnexpectedTypeException($constraint, Blank::class);
    }
    if ('' !== $value && null !== $value) {
        $this->context
            ->buildViolation($constraint->message)
            ->setParameter('{{ value }}', $this->formatValue($value))
            ->setCode(Blank::NOT_BLANK_ERROR)
            ->addViolation();
    }
}
RSS feed
Powered by Drupal