1

I have a Request entity with many Interventions like this :

Request.php

    /**
     * @ORM\OneToMany(targetEntity=Intervention::class, mappedBy="request")
     * @Assert\Count(min=1, max=3)
     * @Assert\Valid
     */
    private $interventions;

Interventions.php

     /**
     * @ORM\Column(type="date")
     * @Assert\NotBlank
     * @Assert\GreaterThanOrEqual("today +3 days")
     */
    private $idate;

    /**
     * @ORM\Column(type="smallint", options={"unsigned": true})
     * @Assert\Range(min=0, max=23)
     * @Assert\NotBlank
     */
    private $ifrom;

    /**
     * @ORM\Column(type="smallint", options={"unsigned": true})
     * @Assert\Range(min=0, max=23)
     * @Assert\NotBlank
     */
    private $ito;

I want to validate that in the case of multiple interventions that the idate is unique. How to do ?

I have see that for @Assert\Unique constraint : 6.1 The fields option was introduced in Symfony 6.1.. But i am using Symfony 5.4...

Thanks

barbuslex
  • 340
  • 3
  • 14

1 Answers1