<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

use Fifa\ConnectId\Sdk\Api\Model\FindOrganisationsRequestType;
use Fifa\ConnectId\Sdk\Registration\ValidationException;

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

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

        $numberOfResultsPropertyName = $validationSubjectName.".numberOfResults";
        ApiModelValidator::mustBeNullOrLessOrEqual($validationSubject->getNumberOfResults(), ValidationConstants::ORGANISATION_SEARCH_RESULTS_UPPER_BOUNDARY, $numberOfResultsPropertyName);
        ApiModelValidator::mustBeNullOrGreaterOrEqual($validationSubject->getNumberOfResults(), ValidationConstants::ORGANISATION_SEARCH_RESULTS_LOWER_BOUNDARY, $numberOfResultsPropertyName);

        ApiModelValidator::validateAllowNull($validationSubject->getParentOrganisationFIFAId(), FifaIdValidator::class, $validationSubjectName.".parentOrganisationFIFAId");
        ApiModelValidator::validateAllowNull($validationSubject->getOrganisationNature(), OrganisationNatureValidator::class, $validationSubjectName.".organisationNature");
        ApiModelValidator::validateAllowNull($validationSubject->getOfficialAddress(), SearchAddressTypeValidator::class, $validationSubjectName.".officialAddress");
    }
}