feat: body dimensions mandatory with selected rentals, updated help text
feat: body dimensions mandatory with selected rentals
This commit is contained in:
@@ -22,6 +22,7 @@ class ParticipantValidator extends ConstraintValidator
|
||||
$participant = $value;
|
||||
|
||||
$this->assertPickupSelected($participant);
|
||||
$this->assertBodyDimensionsWhenRentalsSelected($participant);
|
||||
}
|
||||
|
||||
public function assertPickupSelected(ParticipantDto $participant): void
|
||||
@@ -40,4 +41,34 @@ class ParticipantValidator extends ConstraintValidator
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function assertBodyDimensionsWhenRentalsSelected(ParticipantDto $participant): void
|
||||
{
|
||||
// Check if any rental services are selected
|
||||
if (true === empty($participant->rentals)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Require body dimensions when rentals are selected
|
||||
if (null === $participant->height || '' === $participant->height) {
|
||||
$this->context->buildViolation('Bitte auswählen')
|
||||
->atPath('height')
|
||||
->addViolation()
|
||||
;
|
||||
}
|
||||
|
||||
if (null === $participant->weight || '' === $participant->weight) {
|
||||
$this->context->buildViolation('Bitte auswählen')
|
||||
->atPath('weight')
|
||||
->addViolation()
|
||||
;
|
||||
}
|
||||
|
||||
if (null === $participant->shoeSize || '' === $participant->shoeSize) {
|
||||
$this->context->buildViolation('Bitte auswählen')
|
||||
->atPath('shoeSize')
|
||||
->addViolation()
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user