public static function checkFields($result, $primary, array $data) { parent::checkFields($result, $primary, $data); foreach (static::getEntity()->getFields() as $field) { $error = false; if ($field->getName() == 'LATITUDE' && 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' && 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 Entity\FieldError($field, $error, Entity\FieldError::INVALID_VALUE)); } } }