<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

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

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

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

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

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

        ApiModelValidator::validateAllowNull($validationSubject->getOfficialAddress(), SearchAddressTypeValidator::class, $validationSubjectName.".officialAddress");
    }
}