密码格式验证

@param string $password
@param int    $minLength
@param int    $maxLength

@return bool
762583
static public function validPassword($password, $minLength = 6, $maxLength = 18)
    {
        if (!preg_match('/^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,12}$/', $password)) {
            return false;
        }
        $length = strlen($password);
        if ($length < $minLength || $length > $maxLength) {
            return false;
        }

        return true;
    }
211652
public function maxlength($length = null, $addFilter = true, $utf8 = true)
    {
        if ($addFilter) {
            $this->addFilter(new MaxLengthFilter($length, $utf8));
        }

        return $this->attr('maxlength', $length);
    }
308886
public static function isString($var, $minLenght = false, $maxLenght = false) {
        if (!is_string($var))
            return false;
        if ($minLenght && strlen($var) < $minLenght)
            return false;
        if ($maxLenght && strlen($var) > $maxLenght)
            return false;
        return true;
    }
218562
public static function rangeNumber($value, $minNumber, $maxNumber): bool
    {
        if (!is_numeric($value)) {
            return false;
        }

        if ($value < $minNumber) {
            return false;
        }
        if ($value > $maxNumber) {
            return false;
        }

        return true;
    }
230100
public function eatSpan($mask, $maxLength = null)
    {
        if (null === $maxLength) {
            $maxLength = $this->getRemainingByteCount();
        }

        return $this->read(strspn($this->data, $mask, $this->offset, $maxLength));
    }
369505
public static function checkMinLength($field, $minLength, $msg)
    {
        if ((StringUtils::isEmpty($field) === false) && mb_strlen($field) < $minLength) {
            throw new MsgException($msg);
        }
    }
209097
public static function ruleLenRange($min, $max)
    {
        return function ($input) use ($min, $max) {
            return strlen($input) >= $min && strlen($input) <= $max;
        };
    }
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;
    }
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;
    }
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;
    }
860420
public static function length_in_range(string $str, $min=null, $max=null) {
		if ((null !== $min) && ! \is_int($min)) {
			ref\cast::int($min, true);
		}
		if ((null !== $max) && ! \is_int($max)) {
			ref\cast::int($max, true);
		}

		$length = mb::strlen($str);
		if ((null !== $min) && (null !== $max) && $min > $max) {
			static::switcheroo($min, $max);
		}

		if ((null !== $min) && $min > $length) {
			return false;
		}

		if ((null !== $max) && $max < $length) {
			return false;
		}

		return true;
	}
1089749
public String getRandomText(final int minLength, final int maxLength) {
    validateMinMaxParams(minLength, maxLength);

    StringBuilder sb = new StringBuilder(maxLength);
    int length = minLength;
    if (maxLength != minLength) {
      length = length + random.nextInt(maxLength - minLength);
    }
    while (length > 0) {
      if (sb.length() != 0) {
        sb.append(" ");
        length--;
      }
      final double desiredWordLengthNormalDistributed = 1.0 + Math.abs(random.nextGaussian()) * 6;
      int usedWordLength = (int) (Math.min(length, desiredWordLengthNormalDistributed));
      String word = getRandomWord(usedWordLength);
      sb.append(word);
      length = length - word.length();
    }
    return sb.toString();

  }
193363
public static boolean isLimited(String string, int min, int max) {
        return isNotEmpty(string) && string.length() >= min && string.length() <= max;
    }
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;
    }
1145142
public function setMaxLength($maxLength)
    {
        if (!is_integer($maxLength)) {
            throw new InvalidArgumentException(
                'Max length must be an integer.'
            );
        }

        if ($maxLength < 0) {
            throw new InvalidArgumentException(
                'Max length must be a positive integer (>=0).'
            );
        }

        $this->maxLength = $maxLength;

        return $this;
    }
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;
    }
83387
public function _validation_min_length($val, $length)
	{
		return $this->_empty($val) || \Str::length($val) >= $length;
	}