• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/lib/validator.php
  • Класс: BitrixBizprocValidator
  • Вызов: Validator::validateString
public function validateString(string $name, int $minLen = 0, int $maxLen = 0): self
{
	if (!isset($this->dirtyValues[$name]))
	{
		return $this;
	}

	$val = $this->dirtyValues[$name];

	if (!is_string($val))
	{
		throw new ValidationException(Loc::getMessage("BIZPROC_VALIDATOR_IS_STRING", ["#name#" => $name]));
	}

	if ($minLen && mb_strlen($val) < $minLen)
	{
		throw new ValidationException(Loc::getMessage("BIZPROC_VALIDATOR_STRING_MIN",
			["#name#" => $name, '#min#' => $minLen]));
	}

	if ($maxLen && mb_strlen($val) > $maxLen)
	{
		throw new ValidationException(Loc::getMessage("BIZPROC_VALIDATOR_STRING_MAX",
			["#name#" => $name, '#max#' => $maxLen]));
	}

	$this->setPureValue($name);
	return $this;
}