wip: rentals insurance field

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 3063a7c05f
commit b84997d058
13 changed files with 315 additions and 83 deletions
+4 -40
View File
@@ -10,7 +10,6 @@ use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
#[AppAssert\Participant(groups: ['booking_edit'])]
#[Assert\Callback('validateBodyDimensionsForRentals', groups: ['booking_create_step_2', 'booking_edit'])]
class ParticipantDto
{
public ?int $index = null;
@@ -51,6 +50,10 @@ class ParticipantDto
public ?Service $skiPass = null;
public array $board = [];
public array $rentals = [];
public ?Service $rentalInsurance = null;
// Rental insurance checkbox state (boolean: true if rental insurance requested)
public bool $rentalInsuranceSelected = false;
// Transportation services with improved naming (outbound/inbound)
public ?Service $transportationOutbound = null;
@@ -103,43 +106,4 @@ class ParticipantDto
return 'O' === $this->status;
}
/**
* Validates that body dimension fields are provided when rental services are selected.
*
* This callback validator ensures that height, weight, and shoe size are mandatory
* when the participant has selected any rental services. This is required for
* proper equipment sizing and rental fulfillment.
*
* @param ExecutionContextInterface $context The validation context
*/
public function validateBodyDimensionsForRentals(ExecutionContextInterface $context): void
{
$rentals = $this->rentals ?? [];
// If no rental services are selected, body dimensions are not required
if (empty($rentals)) {
return;
}
// Validate height field
if (true === empty($this->height)) {
$context->buildViolation('Deine Körpergröße ist erforderlich wenn Leihmaterial ausgewählt wurde')
->atPath('height')
->addViolation();
}
// Validate weight field
if (true === empty($this->weight)) {
$context->buildViolation('Dein Gewicht ist erforderlich wenn Leihmaterial ausgewählt wurde')
->atPath('weight')
->addViolation();
}
// Validate shoe size field
if (true === empty($this->shoeSize)) {
$context->buildViolation('Deine Schuhgröße ist erforderlich wenn Leihmaterial ausgewählt wurde')
->atPath('shoeSize')
->addViolation();
}
}
}