move validation on person into annotations

This commit is contained in:
2021-09-01 16:06:20 +02:00
parent 7faddbe3fe
commit 41d76542b4
9 changed files with 165 additions and 97 deletions

View File

@@ -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%";
}

View File

@@ -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();
}

View File

@@ -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";