<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

use Fifa\ConnectId\Sdk\Api\Model\LocalNameType;
use Fifa\ConnectId\Sdk\Registration\ValidationException;
use Fifa\ConnectId\Sdk\Util\Data\ISO6392LanguageCode;

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

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

        ApiModelValidator::cannotBeNullOrWhitespace($validationSubject->getName(), $validationSubjectName.".name");

        $languagePropertyName = $validationSubjectName.".language";
        ApiModelValidator::cannotBeNullOrWhitespace($validationSubject->getLanguage(), $languagePropertyName);
        $ignoreCase = false;
        ApiModelValidator::mustMatchEnumValue($validationSubject->getLanguage(), XsdSchemaValuesResolver::getValues(ISO6392LanguageCode::class), $languagePropertyName, $ignoreCase);
    }
}