<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

use Fifa\ConnectId\Sdk\Api\Model\FieldType;
use Fifa\ConnectId\Sdk\Registration\ValidationException;
use Fifa\ConnectId\Sdk\Util\Data\Discipline;
use Fifa\ConnectId\Sdk\Util\Data\GroundNature;

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

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

        ApiModelValidator::mustBeGreaterOrEqual($validationSubject->getOrderNumber(), ValidationConstants::FACILITY_FIELD_ORDER_NUMBER_LOWER_BOUNDARY, $validationSubjectName.".orderNumber");
        ApiModelValidator::mustBeGreaterOrEqual($validationSubject->getCapacity(), ValidationConstants::FACILITY_FIELD_CAPACITY_LOWER_BOUNDARY, $validationSubjectName.".capacity");

        ApiModelValidator::mustMatchEnumValue($validationSubject->getDiscipline(), Discipline::getDisciplines(), $validationSubjectName.".discipline");
        ApiModelValidator::mustMatchEnumValue($validationSubject->getGroundNature(), GroundNature::getGroundNatures(), $validationSubjectName.".groundNature");
    }
}