mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
move validation on person into annotations
This commit is contained in:
@@ -29,9 +29,11 @@ use Symfony\Component\Validator\Constraint;
|
||||
* (this interval_spec itself is based on ISO8601 :
|
||||
* https://en.wikipedia.org/wiki/ISO_8601#Durations)
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @Annotation
|
||||
*/
|
||||
class Birthdate extends Constraint
|
||||
{
|
||||
public const BIRTHDATE_INVALID_CODE = '3f42fd96-0b2d-11ec-8cf3-0f3b1b1ca1c4';
|
||||
|
||||
public $message = "The birthdate must be before %date%";
|
||||
}
|
||||
|
@@ -53,6 +53,7 @@ class BirthdateValidator extends ConstraintValidator
|
||||
if ($limitDate < $value) {
|
||||
$this->context->buildViolation($constraint->message)
|
||||
->setParameter('%date%', $limitDate->format('d-m-Y'))
|
||||
->setCode(Birthdate::BIRTHDATE_INVALID_CODE)
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Chill\PersonBundle\Validator\Constraints\Person;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
class PersonHasCenter extends \Symfony\Component\Validator\Constraint
|
||||
{
|
||||
public string $message = "A center is required";
|
||||
|
Reference in New Issue
Block a user