<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

use DateTime;
use Fifa\ConnectId\Sdk\Registration\ValidationException;

class DateOfBirthValidator
{
    /**
     * Method that validates date of birth provided and throws exception when it is invalid
     *
     * @param DateTime|null $validationSubject
     * @param string $validationSubjectName
     * @return void
     * @throws ValidationException
     */
    public static function validate(?DateTime $validationSubject, string $validationSubjectName)
    {
        $validationSubjectName = ApiModelValidator::resolveValidationSubjectName($validationSubject, $validationSubjectName);
        ApiModelValidator::cannotBeNull($validationSubject, $validationSubjectName);
        ApiModelValidator::mustBeGreaterOrEqual($validationSubject, ValidationConstants::DATE_OF_BIRTH_LOWER_BOUNDARY(), $validationSubjectName);
    }
}