protected function validateMax($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        if (count($args) == 0) {
            throw new ValidatorConfigException('Validator \'max\' has to have defined maximum value');
        }

        $maxSize = $args[0] ?? null;

        if (!is_numeric($maxSize)) {
            throw new ValidatorConfigException('Validator \'max\' has non-numeric value');
        }

        $maxSize = (int)$maxSize;

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

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

        if (is_array($value) && in_array('array', $rules)) {
            if (count($value) > $maxSize) {
                return Message::getMessage(Message::MAX_VALUE, [
                    'param' => $parameter,
                    'max' => $maxSize,
                    'value' => ''
                ]);
            }

            return null;
        }

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

        $value = (string)$value;

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

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

        $value += 0;

        if ($value > $maxSize) {
            return Message::getMessage(Message::MAX_VALUE, [
                'param' => $parameter,
                'max' => $maxSize,
                'value' => $value
            ]);
        }

        return null;
    }