<?php

namespace Fifa\ConnectId\Sdk\ApiModelValidation;

use Fifa\ConnectId\Sdk\Registration\ValidationException;

class SystemIdValidator
{
    const PATTERN = '/^[0-9A-NP-Z]{6}[0-9A-NP-U](_[a-zA-Z0-9]{3,})?$/';

    /**
     * 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)
            ? "SYSTEM ID"
            : $validationSubjectName;

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