Forráskód Böngészése

add subdomains format validation

Olivier Massot 3 éve
szülő
commit
89686e9108
1 módosított fájl, 2 hozzáadás és 0 törlés
  1. 2 0
      src/Entity/Organization/Subdomain.php

+ 2 - 0
src/Entity/Organization/Subdomain.php

@@ -10,6 +10,7 @@ use ApiPlatform\Core\Annotation\ApiResource;
 use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
 use Symfony\Component\Serializer\Annotation\Groups;
 use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
+use Symfony\Component\Validator\Constraints as Assert;
 
 /**
  * Sous-domaine enregistré par une organisation
@@ -44,6 +45,7 @@ class Subdomain
 
     #[ORM\Column(type: 'string', length: 60, unique: true, nullable: false)]
     #[Groups("subdomain")]
+    #[Assert\Regex('/^[\w\-]+$/', 'Subdomains can not contains whitespaces or special characters')]
     private string $subdomain;
 
     #[ORM\Column(options: ['default' => false])]