feat: ensure teamer accepts terms when confirming driver's license

This commit is contained in:
Björn Fromme
2026-03-15 12:42:28 +01:00
parent 3b6ebdaddc
commit 3d71dcfc14
3 changed files with 52 additions and 14 deletions
+29 -1
View File
@@ -3,11 +3,26 @@
namespace App\Model;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
class DriverLicenseDeclarationDto
{
#[Assert\NotNull(message: 'Bitte gib an, ob du einen Führerschein hast.')]
private ?bool $hasDriverLicense = null;
private ?bool $hasDriverLicense;
private ?bool $confirmTermsOfUse = false;
#[Assert\Callback]
public function validateTermsOfUse(ExecutionContextInterface $executionContext): void
{
if (true === $this->hasDriverLicense() && true !== $this->getConfirmTermsOfUse()) {
$executionContext
->buildViolation('Bitte bestätige die KfZ-Nutzungsbedingungen.')
->atPath('confirmTermsOfUse')
->addViolation()
;
}
}
public function __construct(?bool $hasDriverLicense = null)
{
@@ -25,4 +40,17 @@ class DriverLicenseDeclarationDto
return $this;
}
public function getConfirmTermsOfUse(): ?bool
{
return $this->confirmTermsOfUse;
}
public function setConfirmTermsOfUse(?bool $confirmTermsOfUse): static
{
$this->confirmTermsOfUse = $confirmTermsOfUse;
return $this;
}
}