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

Breadcrumb

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

function UuidValidator::validate

Overrides ConstraintValidatorInterface::validate

File

vendor/symfony/validator/Constraints/UuidValidator.php, line 62

Class

UuidValidator
Validates whether the value is a valid UUID (also known as GUID).

Namespace

Symfony\Component\Validator\Constraints

Code

public function validate(mixed $value, Constraint $constraint) : void {
    if (!$constraint instanceof Uuid) {
        throw new UnexpectedTypeException($constraint, Uuid::class);
    }
    if (null === $value || '' === $value) {
        return;
    }
    if (!\is_scalar($value) && !$value instanceof \Stringable) {
        throw new UnexpectedValueException($value, 'string');
    }
    $value = (string) $value;
    if (null !== $constraint->normalizer) {
        $value = ($constraint->normalizer)($value);
    }
    if ($constraint->strict) {
        $this->validateStrict($value, $constraint);
        return;
    }
    $this->validateLoose($value, $constraint);
}

API Navigation

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