feat: require all personal data fields for registration

This commit is contained in:
Björn Fromme
2026-03-16 12:02:59 +01:00
parent 3957f6bd09
commit 02ebddc34a
5 changed files with 88 additions and 45 deletions
+39 -3
View File
@@ -1,7 +1,11 @@
<?php
declare(strict_types=1);
namespace App\Form\Model;
use App\BusProNet\Model\Address;
use App\BusProNet\Model\Communication;
use Symfony\Component\Validator\Constraints as Assert;
class RegistrationDto
@@ -13,10 +17,42 @@ class RegistrationDto
public ?string $name = null;
#[Assert\NotBlank(message: 'Bitte angeben')]
#[Assert\Choice(choices: ['M', 'W', 'd'])]
#[Assert\Choice(choices: ['M', 'W', 'D'], message: 'Bitte gib einen gültigen Wert an')]
public ?string $gender = null;
#[Assert\NotBlank(message: 'Bitte angeben')]
#[Assert\Email(message: 'Bitte eine gültige E-Mail Adresse angeben', mode: 'strict')]
public ?string $email = null;
public ?\DateTimeImmutable $dateOfBirth = null;
#[Assert\NotBlank(message: 'Bitte angeben')]
public ?string $nationality = null;
#[Assert\Valid]
public Address $address;
#[Assert\Valid]
public Communication $communication;
public function __construct()
{
$this->address = new Address();
$this->communication = new Communication();
}
/**
* Converts the registration data to API payload format.
*
* @return array<string, mixed>
*/
public function toPayload(): array
{
return [
'geschlecht' => $this->gender,
'vorname' => $this->firstName,
'name' => $this->name,
'nationalitaet' => $this->nationality,
'geburtsdatum' => $this->dateOfBirth?->format('d.m.Y'),
'anschrift' => $this->address->toPayload(),
'kommunikation' => $this->communication->toPayload(),
];
}
}