<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

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

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

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

        ApiModelValidator::mustBeNullOrMatchEnumValue($validationSubject->getGender(), Gender::getGenders(), $validationSubjectName.".gender");

        DateOfBirthValidator::validate($validationSubject->getDateOfBirth(), $validationSubjectName.".dateOfBirth");

        ApiModelValidator::validateAllInCollectionAllowNull($validationSubject->getPlayerRegistrations(), PlayerRegistrationTypeValidator::class, $validationSubjectName.".playerRegistrations");

        ApiModelValidator::validateAllInCollectionAllowNull($validationSubject->getMatchOfficialRegistrations(), MatchOfficialRegistrationTypeValidator::class, $validationSubjectName.".matchOfficialRegistrations");

        ApiModelValidator::validateAllInCollectionAllowNull($validationSubject->getTeamOfficialRegistrations(), TeamOfficialRegistrationTypeValidator::class, $validationSubjectName.".teamOfficialRegistrations");

        ApiModelValidator::validateAllInCollectionAllowNull($validationSubject->getOrganisationOfficialRegistrations(), OrganisationOfficialRegistrationTypeValidator::class, $validationSubjectName.".organisationOfficialRegistrations");
    }
}