protected function validateUnique($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        if (count($args) < 2) {
            throw new ValidatorConfigException("Validator 'unique' must have at least two defined arguments; parameter={$parameter}");
        }

        array_walk($args, 'trim');

        if ($args[0] == '') {
            throw new ValidatorConfigException("Validator 'unique' must have non-empty string for argument=0; parameter={$parameter}");
        }

        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (!is_scalar($value)) {
            return Message::getMessage(Message::PRIMITIVE, [
                'param' => $parameter
            ]);
        }

        $value = trim((string)$value);

        if ($value === '') {
            return null;
        }

        for ($i = count($args); $i < 4; $i++) {
            if (!isset($args[$i])) {
                $args[$i] = null;
            }
        }

        /** @var Model $modelClass */
        list($modelClass, $uniqueField, $exceptionValue, $exceptionField) = $args;

        if (is_string($exceptionValue)) {
            if (substr($exceptionValue, 0, 6) == 'field:') {
                $exceptionFieldName = substr($exceptionValue, 6);
                $exceptionFieldValue = $context[$exceptionFieldName] ?? null;

                if ($exceptionFieldValue === null) {
                    throw new ValidatorConfigException("Can not validate unique parameter={$parameter} when exception field name={$exceptionFieldName} is not present or has the value of null");
                }

                $exceptionValue = $exceptionFieldValue;
            } else {
                $exceptionValue = urldecode(trim($exceptionValue));
            }
        }

        if (!$modelClass::isUnique($uniqueField, $value, $exceptionValue, $exceptionField)) {
            return Message::getMessage(Message::NOT_UNIQUE, [
                'param' => $parameter,
                'value' => $value,
                'exceptionField' => $exceptionField,
                'exceptionValue' => $exceptionValue
            ]);
        }

        return null;
    }