wip: rentals insurance field
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user