rdv: add validation

This commit is contained in:
nobohan 2021-07-19 16:15:52 +02:00
parent d542f582e6
commit d4ec5d137e

View File

@ -16,6 +16,9 @@ use Chill\CalendarBundle\Entity\CalendarRange;
use Chill\CalendarBundle\Entity\Invite;
use Chill\ActivityBundle\Entity\Activity;
use Chill\CalendarBundle\Repository\CalendarRepository;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* @ORM\Table(name="chill_calendar.calendar")
@ -412,4 +415,20 @@ class Calendar
{
return $this->getInvites(); //TODO get users of the invite
}
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('startDate', new NotBlank());
$metadata->addPropertyConstraint('startDate', new Range([
'min' => '2 years ago',
'max' => '+ 2 years',
]));
$metadata->addPropertyConstraint('endDate', new NotBlank());
$metadata->addPropertyConstraint('endDate', new Range([
'min' => '2 years ago',
'max' => '+ 2 years',
]));
}
}