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\ConstraintsCode
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);
}