<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

use Fifa\ConnectId\Sdk\Registration\ValidationException;

class FifaIdValidator
{
    const PATTERN = '/^[0-9A-NP-Z]{6}[0-9A-NP-U]$/';

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

        ApiModelValidator::mustMatchPattern($validationSubject, self::PATTERN, $validationSubjectName);
    }
}