fix: correctly handle email uniqueness by excluding the applicant from validation

This commit is contained in:
Björn Fromme
2025-12-06 15:02:13 +01:00
parent 2b3a8f1c69
commit 5b55d0984a
+11 -4
View File
@@ -121,15 +121,22 @@ class ParticipantEditDto
} }
/** /**
* Validates that adult participants have unique email addresses. * Validates that non-applicant adult participants have unique email addresses.
* *
* Children (under 16) are exempt from this validation and can share * Exempt from validation:
* email addresses with adults. Email comparison is case-insensitive * - Applicant (index 0): Can share email with dependents they're booking for
* and whitespace is normalized. * - Children (under 16): Can share email addresses with adults
*
* Email comparison is case-insensitive and whitespace is normalized.
*/ */
#[Assert\Callback(groups: ['booking_create', 'booking_edit'])] #[Assert\Callback(groups: ['booking_create', 'booking_edit'])]
public function validateEmailUniqueness(ExecutionContextInterface $context): void public function validateEmailUniqueness(ExecutionContextInterface $context): void
{ {
// Skip validation for applicant (index 0) - applicant's email can be shared with dependents
if (true === $this->participant->isApplicant()) {
return;
}
// Skip validation for children (under 16) // Skip validation for children (under 16)
if (true === $this->participant->isChild()) { if (true === $this->participant->isChild()) {
return; return;