Browse Source

fix après tests

Vincent 3 months ago
parent
commit
121e31efec

+ 6 - 1
src/ApiResources/Freemium/FreemiumEvent.php

@@ -29,6 +29,7 @@ use App\Validator\Constraints as OpentalentAssert;
 use Doctrine\Common\Collections\ArrayCollection;
 use JetBrains\PhpStorm\Pure;
 use Symfony\Component\ObjectMapper\Attribute\Map;
+use Symfony\Component\Validator\Constraints as Assert;
 
 /**
  * Classe resource contient tous les champs pour la gestion d'un événement pour un profile Freemium.
@@ -64,6 +65,7 @@ use Symfony\Component\ObjectMapper\Attribute\Map;
 #[ApiFilter(filterClass: OrderFilter::class, properties: ['datetimeStart'], arguments: ['orderParameterName' => 'order'])]
 #[Map(source: Event::class)]
 #[OpentalentAssert\FieldLesserThan(field: 'datetimeStart', comparedTo: 'datetimeEnd')]
+#[OpentalentAssert\FieldLesserThan(field: 'priceMini', comparedTo: 'priceMaxi')]
 class FreemiumEvent implements ApiResourcesInterface
 {
     #[ApiProperty(identifier: true)]
@@ -81,8 +83,10 @@ class FreemiumEvent implements ApiResourcesInterface
 
     public ?File $image = null;
 
+    #[Assert\Url(protocols: ['http', 'https'])]
     public ?string $url = null;
 
+    #[Assert\Url(protocols: ['http', 'https'])]
     public ?string $urlTicket = null;
 
     public ?Place $place = null;
@@ -119,8 +123,9 @@ class FreemiumEvent implements ApiResourcesInterface
 
     public ?PricingEventEnum $pricing = null;
 
+    #[Assert\Positive()]
     public ?float $priceMini = null;
-
+    #[Assert\Positive()]
     public ?float $priceMaxi = null;
 
     #[Pure]

+ 4 - 0
src/ApiResources/Freemium/FreemiumOrganization.php

@@ -79,15 +79,19 @@ class FreemiumOrganization implements ApiResourcesInterface
     public ?float $longitude = null;
 
     #[Assert\Length(max: 255)]
+    #[Assert\Url(protocols: ['http', 'https'])]
     public ?string $facebook = null;
 
     #[Assert\Length(max: 255)]
+    #[Assert\Url(protocols: ['http', 'https'])]
     public ?string $twitter = null;
 
     #[Assert\Length(max: 255)]
+    #[Assert\Url(protocols: ['http', 'https'])]
     public ?string $youtube = null;
 
     #[Assert\Length(max: 255)]
+    #[Assert\Url(protocols: ['http', 'https'])]
     public ?string $instagram = null;
 
     public bool $portailVisibility = true;

+ 2 - 2
src/Validator/Constraints/FieldLesserThan.php

@@ -7,10 +7,10 @@ namespace App\Validator\Constraints;
 use Symfony\Component\Validator\Attribute\HasNamedArguments;
 use Symfony\Component\Validator\Constraint;
 
-#[\Attribute(\Attribute::TARGET_CLASS)]
+#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
 class FieldLesserThan extends Constraint
 {
-    public string $message = 'The value of "{{ field }}" must be less than "{{ comparedTo }}"';
+    public string $message = '{{ field }} must be less than {{ comparedTo }}';
 
     #[HasNamedArguments]
     public function __construct(