add validation on calendar

This commit is contained in:
2022-07-01 15:05:03 +02:00
parent 9c1324e9ec
commit 93c5e83454
4 changed files with 23 additions and 7 deletions

View File

@@ -31,6 +31,7 @@ use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use LogicException;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Range;
@@ -113,6 +114,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
* @Serializer\Groups({"calendar:read", "read"})
* @Assert\NotNull(message="calendar.An end date is required")
*/
private ?DateTimeImmutable $endDate = null;
@@ -139,12 +141,14 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
* @Serializer\Groups({"read"})
* @Assert\NotNull(message="calendar.A location is required")
*/
private ?Location $location = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
* @Serializer\Groups({"calendar:read", "read"})
* @Assert\NotNull(message="calendar.A main user is mandatory")
*/
private ?User $mainUser = null;
@@ -152,6 +156,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person")
* @ORM\JoinTable(name="chill_calendar.calendar_to_persons")
* @Serializer\Groups({"calendar:read", "read"})
* @Assert\Count(min=1, minMessage="calendar.At least {{ limit }} person is required.")
*/
private Collection $persons;
@@ -181,6 +186,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
* @Serializer\Groups({"calendar:read", "read"})
* @Assert\NotNull(message="calendar.A start date is required")
*/
private ?DateTimeImmutable $startDate = null;