<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

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

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

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

        ApiModelValidator::cannotBeNullOrWhitespace($validationSubject->getType(), $validationSubjectName.".type");
        ApiModelValidator::cannotBeNullOrWhitespace($validationSubject->getHash(), $validationSubjectName.".hash");

        $proximityScorePropertyName = $validationSubjectName.".proximityScore";
        ApiModelValidator::mustBeGreaterOrEqual($validationSubject->getProximityScore(), ValidationConstants::PROXIMITY_SCORE_LOWER_BOUNDARY, $proximityScorePropertyName);
        ApiModelValidator::mustBeLessOrEqual($validationSubject->getProximityScore(), ValidationConstants::PROXIMITY_SCORE_UPPER_BOUNDARY, $proximityScorePropertyName);
    }
}