• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/entityproperty.php
  • Класс: BitrixSaleEntityProperty
  • Вызов: EntityProperty::checkValue
public function checkValue($value)
{
	$result = new Result();

	static $errors = [];

	if (
		$this->getField('TYPE') === "STRING"
		&& (int)$this->getField('MAXLENGTH') <= 0
	)
	{
		$this->fields['MAXLENGTH'] = 500;
	}

	$error = InputManager::getError($this->fields, $value);

	if (!is_array($error))
	{
		$error = array($error);
	}

	foreach ($error as $item)
	{
		if (!is_array($item))
		{
			$item = [$item];
		}

		foreach ($item as $message)
		{
			if (isset($errorsList[$this->getId()]) && in_array($message, $errors[$this->getId()]))
			{
				continue;
			}

			$result->addError(
				new MainError(
					Loc::getMessage(
						"SALE_PROPERTY_ERROR",
						["#PROPERTY_NAME#" => $this->getField('NAME'), "#ERROR_MESSAGE#" => $message]
					)
				)
			);
		}
	}

	if (!is_array($value) && isset($value))
	{
		$value = trim((string)$value);

		if ($value !== '' && $this->getField('IS_EMAIL') === 'Y')
		{
			if (!check_email($value, true))
			{
				$result->addError(
					new MainError(
						Loc::getMessage("SALE_GOPE_WRONG_EMAIL")
					)
				);
			}
		}
	}

	return $result;
}