implements::validate

  1. Bitrix24 API (v. 23.675.0)
  2. ui
  3. implements
  4. validate
  • Модуль: ui
  • Путь к файлу: ~/bitrix/modules/ui/lib/barcode/datagenerator/financialtransactionsru.php
  • Класс: BitrixUIBarcodeDataGeneratorimplements
  • Вызов: implements::validate
public function validate(): Result
{
	$result = new Result();

	$mandatoryFieldNames = $this->getMandatoryFieldNames();
	foreach ($mandatoryFieldNames as $mandatoryFieldName)
	{
		if (empty($this->fields[$mandatoryFieldName]))
		{
			$result->addError(
				new Error(
					'Mandatory field ' . $mandatoryFieldName . ' is not filled',
					static::ERROR_CODE_MANDATORY_FIELD_IS_NOT_FILLED,
				)
			);
		}
	}
	foreach ($this->fields as $fieldName => $value)
	{
		if (!$this->isValueTypeValid($value))
		{
			$result->addError(
				new Error(
					'Incorrect value type ' . $fieldName,
					static::ERROR_CODE_VALUE_INCORRECT_TYPE,
				)
			);
			continue;
		}
		$value = (string)$value;

		$maxFieldLength = $this->getFieldValueMaximumLength($fieldName);
		if ($maxFieldLength > 0 && mb_strlen($value) > $maxFieldLength)
		{
			$result->addError(
				new Error(
					'The value of ' . $fieldName . ' is too long',
					static::ERROR_CODE_VALUE_IS_TOO_LONG,
				)
			);
		}
	}

	return $result;
}

Добавить комментарий