<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

use Fifa\ConnectId\Sdk\Api\Model\PlayerRegistrationType;
use Fifa\ConnectId\Sdk\Registration\ValidationException;
use Fifa\ConnectId\Sdk\Util\Data\Discipline;
use Fifa\ConnectId\Sdk\Util\Data\Person\Level;
use Fifa\ConnectId\Sdk\Util\Data\RegistrationNature;
use Fifa\ConnectId\Sdk\Util\Data\Status;

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

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

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

        ApiModelValidator::mustMatchEnumValue($validationSubject->getLevel(), Level::getLevels(), $validationSubjectName.".level"); // FDS non-compliant coz of Id Directory implementation
        ApiModelValidator::mustMatchEnumValue($validationSubject->getStatus(), Status::getStatuses(), $validationSubjectName.".status");
        ApiModelValidator::mustMatchEnumValue($validationSubject->getDiscipline(), Discipline::getDisciplines(), $validationSubjectName.".discipline");
        ApiModelValidator::mustBeNullOrMatchEnumValue($validationSubject->getRegistrationNature(), RegistrationNature::getRegistrationNatures(), $validationSubjectName.".registrationNature");
        ApiModelValidator::validateAllowNull($validationSubject->getSystemId(), SystemIdValidator::class, $validationSubjectName.".systemId");
    }
}