fix: correctly handle email uniqueness by excluding the applicant from validation
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user