From a3d6f0d5a8ed283597f7f711723c6ef2ca098612 Mon Sep 17 00:00:00 2001 From: Alan Poulain Date: Fri, 19 Mar 2021 18:54:56 +0100 Subject: [PATCH] fix: manage Ulid in format property schema restriction --- .../Metadata/Property/Restriction/PropertySchemaFormat.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Bridge/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaFormat.php b/src/Bridge/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaFormat.php index 2f66b789005..c6cec232b6f 100644 --- a/src/Bridge/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaFormat.php +++ b/src/Bridge/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaFormat.php @@ -17,6 +17,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\Ip; +use Symfony\Component\Validator\Constraints\Ulid; use Symfony\Component\Validator\Constraints\Uuid; /** @@ -39,6 +40,10 @@ public function create(Constraint $constraint, PropertyMetadata $propertyMetadat return ['format' => 'uuid']; } + if ($constraint instanceof Ulid) { + return ['format' => 'ulid']; + } + if ($constraint instanceof Ip) { if ($constraint->version === $constraint::V4) { return ['format' => 'ipv4']; @@ -57,6 +62,6 @@ public function supports(Constraint $constraint, PropertyMetadata $propertyMetad { $schema = $propertyMetadata->getSchema(); - return empty($schema['format']); + return empty($schema['format']) && ($constraint instanceof Email || $constraint instanceof Uuid || $constraint instanceof Ulid || $constraint instanceof Ip); } }