Validate string from GET parameter - $_GET["key"].

@param string $key
@param integer $minLength
@param mixed $maxLength Integer or false when there is no limit
@param mixed $default - default value will be returned if validation fails

@return mixed
327478
public function strGet($key, $minLength = 0, $maxLength = false, $default = false)
	{
		return $this->str($this->get($key), $minLength, $maxLength, $default);
	}
86581
public function plainSession($key, $minLength = 0, $maxLength = false, $default = false)
	{
		return $this->plain($this->session($key), $minLength, $maxLength, $default);
	}
40333
public static String validate(String value, int min, int max) {
        if (min == max) {
            return validate(value, min);
        }
        if ((value.length() < min) || (value.length() > max)) {
            throw new InvalidLengthException(value, min, max);
        }
        return value;
    }
230100
public function eatSpan($mask, $maxLength = null)
    {
        if (null === $maxLength) {
            $maxLength = $this->getRemainingByteCount();
        }

        return $this->read(strspn($this->data, $mask, $this->offset, $maxLength));
    }
886709
def _validate_maxlength(self, max_length, field, value):
        
        if isinstance(value, Iterable) and len(value) > max_length:
            self._error(field, errors.MAX_LENGTH, len(value))
1035569
public function rule_min( $key, $value, $min )
	{
		return $this->rule_min_num( $key, strlen( $value ), $min );
	}
415668
public String get(String key, String defaultString) {
    if (!containsKey(key)) {
      return defaultString;
    }
    return get(key);
  }
829327
public function lengthBetween($field, $min, $max, $inclusive = false)
    {
        $fieldValue = strlen(trim($this->get($field)));

        $valid = ($fieldValue <= $max && $fieldValue >= $min);

        if (!$inclusive) {
            $valid = ($fieldValue < $max && $fieldValue > $min);
        }

        return ($valid === true) ?: $this->error($field, __FUNCTION__);
    }
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));
    }
1068504
static public function betweenLength($value, $minLength, $maxLength, $message = null, $propertyPath = null, $encoding = 'utf8')
        {
            static::string($value, $message);

            if (mb_strlen($value, $encoding) < $minLength) {
                $message = $message ?: sprintf(
                    'Value "%s" is too short, it should have more than %d characters, but only has %d characters.',
                    static::stringify($value),
                    $minLength,
                    mb_strlen($value, $encoding)
                );

                $constraints = array('min_length' => $minLength, 'encoding' => $encoding);

                throw static::createException($value, $message, static::INVALID_MIN_LENGTH, $propertyPath, $constraints);
            }

            if (mb_strlen($value, $encoding) > $maxLength) {
                $message = $message ?: sprintf(
                    'Value "%s" is too long, it should have no more than %d characters, but has %d characters.',
                    static::stringify($value),
                    $maxLength,
                    mb_strlen($value, $encoding)
                );

                $constraints = array('max_length' => $maxLength, 'encoding' => $encoding);

                throw static::createException($value, $message, static::INVALID_MAX_LENGTH, $propertyPath, $constraints);
            }
        }
722403
public function visitMinimumLengthConstraint(StringValue\MinimumLengthConstraint $constraint)
    {
        $value = $this->currentValue();
        if (
            !$value instanceof Value\StringValue ||
            mb_strlen($value->value(), 'UTF-8') >= $constraint->minimum()
        ) {
            return $this->createResult();
        }

        return $this->createSingleIssueResult($constraint);
    }
1300323
public static Validation<String> length(int minSize, int maxSize) {
        return moreThan(minSize).and(lessThan(maxSize));
    }
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();

  }
1028269
public function get($key, $default = null) {

		if(false === is_string($key) && false === is_array($key)) {
   			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or array, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
   		}

   		if(0 === strlen($key)) {
   			return trigger_error(sprintf('Argument 1 passed to %s() may not be an empty string', __METHOD__), E_USER_ERROR);
   		}

		$result = apcu_fetch($key, $success);

		if(true === $success) {
			return $result;
		}

		return $default;
	}
369505
public static function checkMinLength($field, $minLength, $msg)
    {
        if ((StringUtils::isEmpty($field) === false) && mb_strlen($field) < $minLength) {
            throw new MsgException($msg);
        }
    }
518447
protected function sizeMax($key, $lengthValue, $max, $not = true)
    {
        if (($lengthValue > $max) && $not) {
            $this->addReturn($key, 'must', [ ':max' => $max ]);
        } elseif (!($lengthValue > $max) && !$not) {
            $this->addReturn($key, 'not', [ ':max' => $max ]);
        }
    }
200611
public function rule_max( $key, $value, $max )
	{
		return $this->rule_max_num( $key, strlen( $value ), $max );
	}