wip: first working version
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Form\Model;
|
||||
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
use App\BusProNet\Model\Pickup;
|
||||
use App\BusProNet\Model\Service;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
@@ -47,9 +48,10 @@ class ParticipantData
|
||||
public array $rentals = [];
|
||||
public ?Service $transportationServiceTo = null;
|
||||
public ?Service $transportationServiceFro = null;
|
||||
public ?Pickup $pickup = null;
|
||||
|
||||
#[Assert\Callback]
|
||||
public function assertBodyMeasurements(ExecutionContextInterface $context): void
|
||||
public function assertBodyMeasurementsValid(ExecutionContextInterface $context): void
|
||||
{
|
||||
if (0 === count($this->rentals)) {
|
||||
return;
|
||||
@@ -63,20 +65,31 @@ class ParticipantData
|
||||
}
|
||||
|
||||
if (empty($this->shoeSize)) {
|
||||
$context->buildViolation('Bitte angeben Leihmaterial')
|
||||
$context->buildViolation('Bitte angeben wegen Leihmaterial')
|
||||
->atPath('shoeSize')
|
||||
->addViolation()
|
||||
;
|
||||
}
|
||||
|
||||
if (empty($this->weight)) {
|
||||
$context->buildViolation('Bitte angeben Leihmaterial')
|
||||
$context->buildViolation('Bitte angeben wegen Leihmaterial')
|
||||
->atPath('weight')
|
||||
->addViolation()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
#[Assert\Callback]
|
||||
public function assertPickupSelected(ExecutionContextInterface $context): void
|
||||
{
|
||||
if (null !== $this->transportationServiceTo && null === $this->pickup) {
|
||||
$context->buildViolation('Bitte auswählen')
|
||||
->atPath('pickupTo')
|
||||
->addViolation()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public static function fromPersonalData(PersonalData $personalData): static
|
||||
{
|
||||
$instance = new static();
|
||||
|
||||
Reference in New Issue
Block a user