<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

use Fifa\ConnectId\Sdk\Api\Model\UpdatePersonRequestType;
use Fifa\ConnectId\Sdk\Registration\ValidationException;
use Fifa\ConnectId\Sdk\Util\Data\Gender;

class UpdatePersonRequestTypeValidator
{
    /**
     * Method that validates object provided and throws exception when object's properties are invalid
     *
     * @param UpdatePersonRequestType|null $validationSubject
     * @param string $validationSubjectName
     * @return void
     * @throws ValidationException
     */
    public static function validate(?UpdatePersonRequestType $validationSubject, string $validationSubjectName)
    {
        $validationSubjectName = ApiModelValidator::resolveValidationSubjectName($validationSubject, $validationSubjectName);

        ApiModelValidator::cannotBeNull($validationSubject, $validationSubjectName);

        ApiModelValidator::validateDoNotAllowNull($validationSubject->getPersonId(), FifaIdValidator::class, $validationSubjectName.".personId");

        ApiModelValidator::validateAllInCollectionAllowNull($validationSubject->getNameHashes(), HashedNameTypeValidator::class, $validationSubjectName.".nameHashes");

        ApiModelValidator::mustBeNullOrGreaterOrEqual($validationSubject->getDateOfBirth(), ValidationConstants::DATE_OF_BIRTH_LOWER_BOUNDARY(), $validationSubjectName.".dateOfBirth");
        ApiModelValidator::mustBeNullOrMatchEnumValue($validationSubject->getGender(), Gender::getGenders(), $validationSubjectName.".gender");
    }
}