fix: validate newly entered phone numbers

This commit is contained in:
fromme committed 2026-10-28 13:48:51 +01:00
1 parent e293bd3b1c
commit 7c8dbeef48
11 files changed
+227 -6

No files matched your search

+15
View File
@@ -93,8 +93,17 @@ class ParticipantDto
)]
public ?string $email = null;
#[Assert\When(
expression: 'this.isMobileNewlyEntered()',
constraints: [new AppAssert\PhoneNumber()],
groups: ['booking_edit', 'booking_create'],
)]
public ?string $mobile = null;
// The number as loaded from BusPro, which goes back unchanged and is exempt from PhoneNumber.
// Public so it survives the session round trip through __unserialize().
public ?string $loadedMobile = null;
#[Assert\Valid(groups: ['booking_edit', 'booking_create'])]
#[Assert\NotNull(message: 'Bitte Adresse angeben', groups: ['applicant_address'])]
public ?Address $address = null;
@@ -240,6 +249,7 @@ class ParticipantDto
$instance->nationality = $personalData->nationality ?: 'D';
$instance->email = $personalData->communication->email;
$instance->mobile = $personalData->communication->mobile;
$instance->loadedMobile = $personalData->communication->mobile;
$instance->dateOfBirth = $personalData->dateOfBirth;
$instance->height = $personalData->height;
$instance->weight = $personalData->weight;
@@ -254,6 +264,11 @@ class ParticipantDto
return $instance;
}
public function isMobileNewlyEntered(): bool
{
return AppAssert\PhoneNumber::isNewlyEntered($this->mobile, $this->loadedMobile);
}
public function isApplicant(): bool
{
return 0 === $this->index;