• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/location.php
  • Класс: BitrixSaleLocationLocationTable
  • Вызов: LocationTable::checkFields
static function checkFields(EntityResult $result, $primary, array $data)
{
	parent::checkFields($result, $primary, $data);

	foreach(static::getEntity()->getFields() as $field)
	{
		$error = false;

		if($field->getName() == 'LATITUDE' && mb_strlen($data['LATITUDE']))
		{
			// latitude is set in data and not empty, it must lay between -90 and 90
			if(!is_numeric($data['LATITUDE']))
				$error = Loc::getMessage('SALE_LOCATION_LOCATION_ENTITY_LATITUDE_TYPE_ERROR');
			elseif(($latitude = floatval($data['LATITUDE'])) && ($latitude < -90 || $latitude > 90))
				$error = Loc::getMessage('SALE_LOCATION_LOCATION_ENTITY_LATITUDE_RANGE_ERROR');
		}

		if($field->getName() == 'LONGITUDE' && mb_strlen($data['LONGITUDE']))
		{
			// longitude is set in data and not empty, it must lay between -180 and 180
			if(!is_numeric($data['LONGITUDE']))
				$error = Loc::getMessage('SALE_LOCATION_LOCATION_ENTITY_LONGITUDE_TYPE_ERROR');
			elseif(($longitude = floatval($data['LONGITUDE'])) && ($longitude < -180 || $longitude > 180))
				$error = Loc::getMessage('SALE_LOCATION_LOCATION_ENTITY_LONGITUDE_RANGE_ERROR');
		}

		if($error !== false)
		{
			$result->addError(new EntityFieldError(
				$field,
				$error,
				EntityFieldError::INVALID_VALUE
			));
		}
	}
}