participant->purchaseVoucherCode; // Skip validation if voucher code is empty if (null === $voucherCode || '' === trim($voucherCode)) { return; } // Validate voucher via API $result = $this->voucherValidationService->validatePurchaseVoucher($voucherCode); // Add violation if voucher is invalid if (false === $result->isValid) { $this->context->buildViolation($constraint->message) ->setParameter('{{ error }}', $result->errorMessage ?? 'Unbekannter Fehler') ->atPath('participant.purchaseVoucherCode') ->addViolation(); } } }