check val is a string
@param mixed    $val
@param int      $minLen
@param null|int $maxLen
@return bool
977556
public static function string($val, $minLen = 0, $maxLen = null): bool
    {
        if (!\is_string($val)) {
            return false;
        }

        // only type check.
        if ($minLen === 0 && $maxLen === null) {
            return true;
        }

        return self::integer(Helper::strlen($val), $minLen, $maxLen);
    }
43088
public function isValidStringLength($str, $min = null, $max = null): bool
    {
        $len = mb_strlen($str, 'UTF-8');

        return (($min !== null) && ($len >= $min)) || (($max !== null) && ($len <= $max));
    }
422053
protected static function check($value, $min, $max)
    {
        $length = strlen($value);

        if ($length < $min)
            return self::STATUS_WARNING;

        if ($min <= $length && $length <= $max)
            return self::STATUS_GOOD;

        return self::STATUS_DANGER;
    }
1050849
public static function rangeLength($value, int $minLength, int $maxLength, string $encoding = 'UTF-8'): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        $strlen = (int) mb_strlen((string) $value, $encoding);

        if ($strlen < $minLength) {
            return false;
        }
        if ($strlen > $maxLength) {
            return false;
        }

        return true;
    }
1208061
protected function _validator_maxlength($input, $value, $max) {
		if (!is_string($value)) return false;
		if (strlen($value) > $max) return false;
		return true;
	}
918645
protected function validate_int( $var, $min = null, $max = null ) {
		if ( ! is_int( $var ) && ! is_string( $var ) && empty( $var ) ) {
			return new \WP_Error( 400, $this->app->translate( 'Value is required.' ) );
		}
		if ( ! is_int( $var ) && ( ! is_string( $var ) || ! preg_match( '#\A-?\d+\z#', $var ) ) ) {
			return new \WP_Error( 400, $this->app->translate( 'Invalid format.' ) );
		}
		if ( isset( $min ) && $var < $min ) {
			return new \WP_Error( 400, $this->app->translate( 'Outside the range of allowed values.' ) );
		}
		if ( isset( $max ) && $var > $max ) {
			return new \WP_Error( 400, $this->app->translate( 'Outside the range of allowed values.' ) );
		}

		return true;
	}
912384
private function isValidResult($number, $min, $max)
    {
        return is_int($number) && $number >= $min && $number <= $max;
    }
357086
public static function int($value, $min = null, $max = null)
    {
        // 最小值
        if(null !== $min && $value < $min)
        {
            return false;
        }
        // 最大值
        if(null !== $max && $value > $max)
        {
            return false;
        }
        // 整数验证
        return ((int)$value) == $value;
    }
943911
public static function validate($value, $maxLen, $errorMessage)
    {
        if (mb_strlen($value, 'UTF-8') <= $maxLen) {
            return true;
        }
        throw new DomainError($errorMessage);
    }
1004830
public function whereBetween($expr, $min, $max)
    {
        if ($min === null || $min === '') {
            return $max === null || $max === '' ? $this : $this->whereCmp($expr, '<=', $max);
        } elseif ($max === null || $max === '') {
            return $min === null || $min === '' ? $this : $this->whereCmp($expr, '>=', $min);
        }

        if (strpos($expr, '[') === false && strpos($expr, '(') === false) {

            if (strpos($expr, '.') !== false) {
                $id = strtr($expr, '.', '_');
                $expr = '[' . str_replace('.', '].[', $expr) . ']';

            } else {
                $id = $expr;
                $expr = '[' . $expr . ']';
            }

            $minKey = $id . '_min';
            $maxKey = $id . '_max';
        } else {
            $minKey = '_min_' . $this->_hiddenParamNumber;
            $maxKey = '_max_' . $this->_hiddenParamNumber;
            $this->_hiddenParamNumber++;
        }

        $this->_conditions[] = "$expr BETWEEN :$minKey AND :$maxKey";

        $this->_bind[$minKey] = $min;
        $this->_bind[$maxKey] = $max;

        return $this;
    }
1114621
public static function number($val, $min = null, $max = null, $flags = 0): bool
    {
        if (!\is_numeric($val)) {
            return false;
        }

        if ($val <= 0) {
            return false;
        }

        return self::integer($val, $min, $max, $flags);
    }
888157
function rule_maxlength($val, $error = null) {
        if (!$error) {
            $error = 'Максимум ' . $val . ' ' . \Meerkat\Helper\Helper_Text::plural($val, 'символ', 'символа', 'символов');
        }
        $this->element->addRule('maxlength', $error, $val, \HTML_QuickForm2_Rule::ONBLUR_CLIENT_SERVER);
        return $this;
    }
668078
public static function isLengthLt($value, $min)
    {
        $value = trim($value);
        if (!is_string($value)) {
            return false;
        }
        $length = function_exists('mb_strlen') ? mb_strlen($value, 'UTF-8') : strlen($value);
        is_array($min) && $min = $min[0];

        if ($min != 0 && $length >= $min) return false;
        return true;
    }
1253014
public function whereBetween($field, $min, $max)
    {
        if ($min === null || $min === '') {
            return $max === null || $max === '' ? $this : $this->whereCmp($field, '<=', $max);
        } elseif ($max === null || $max === '') {
            return $min === null || $min === '' ? $this : $this->whereCmp($field, '>=', $min);
        }

        $this->_filters[] = [$field => ['$gte' => $this->normalizeValue($field, $min), '$lte' => $this->normalizeValue($field, $max)]];

        return $this;
    }
909177
public static function isOptionalNumericRange($value, $min, $max)
    {
        /* No additional validations when the value is null. */
        if (null === $value) {

            return true;
        }

        return self::isRequiredNumericRange($value, $min, $max);
    }
1044036
public function length($min, $max = null) {
        if (!$this->_isValid) {
            return $this;
        }
        $c = count($this->_unsafeVar);
        if ($c < $min || (null !== $max && $c > $max)) {
            $this->_isValid = false;
        }
        return $this;
    }
1270407
public function readBytes($maxlen = null)
    {
        $this->log->debug('calling readbytes()', array('maxlen' => $maxlen));
        $out = $this->streamReadBytes($this->stream, $maxlen);
        $this->log->debug('readBytes()', [$maxlen, $out]);

        if (false === $out) {
            $meta = $this->streamMeta($this->stream);
            $this->log->warning('stream_get_contents returned false', $meta);
            throw new StreamException(StreamException::OP_READ, 'stream_get_contents returned false');
        }

        return $out;
    }