feat: enforce profile data completeness before entering booking flow

This commit is contained in:
Björn Fromme
2026-03-16 12:02:59 +01:00
parent 18d60c8781
commit 0a0987873f
7 changed files with 235 additions and 19 deletions
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace App\Service;
use App\BusProNet\Model\PersonalData;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* Validates profile completeness for booking requirements.
*
* Checks whether a user's personal data contains all required fields needed to create
* or edit bookings using Symfony's validation system with the 'personal_data' group.
* Required fields include name, gender, date of birth, nationality, contact information,
* and full address data.
*/
class ProfileCompletenessChecker
{
private const VALIDATION_GROUP = 'personal_data';
public function __construct(
private readonly ValidatorInterface $validator,
) {
}
/**
* Checks if the personal data contains all required fields for booking operations.
*
* Validates against the 'personal_data' group which includes:
* - firstName and name (personal identification)
* - gender and dateOfBirth (personal attributes)
* - nationality (booking form requirement)
* - email and mobile (communication)
* - street, postCode, city, country (applicant address)
*
* @param PersonalData $personalData The personal data to validate
*
* @return bool True if all required fields are present and valid, false otherwise
*/
public function isComplete(PersonalData $personalData): bool
{
$violations = $this->validator->validate($personalData, null, [self::VALIDATION_GROUP]);
return 0 === $violations->count();
}
}