You are here

function feed_import_settings_form_validate in Feed Import 7

Same name and namespace in other branches
  1. 7.2 feed_import.module \feed_import_settings_form_validate()

Settings form validate

File

./feed_import.module, line 421
User interface, cron functions for feed_import module

Code

function feed_import_settings_form_validate($form, &$form_state) {
  $numeric_fields = array(
    'feed_import_time_between_imports',
    'feed_import_delete_items_per_cron',
    'feed_import_insert_hashes_chunk',
    'feed_import_update_ids_chunk',
    'feed_import_entity_info_keep',
    'feed_import_processFeedChunked_chunk_length',
  );

  // Checking numeric fields
  foreach ($numeric_fields as &$field) {
    if (!is_numeric($form_state['values'][$field])) {
      form_error($form[$field], t('Field value must be numeric.'));
    }
  }

  // Checking hash property field (this must be a variable name)
  if (!preg_match("/^[A-Za-z_][A-Za-z0-9_]*\$/", $form_state['values']['feed_import_hash_property'])) {
    form_error($form['feed_import_hash_property'], t('This must be a valid variable name.'));
  }

  // Checking xml head
  if (!preg_match("/^\\<\\?xml (.*)\\?\\>\$/", $form_state['values']['feed_import_processFeedChunked_xml_head'])) {
    form_error($form['feed_import_processFeedChunked_xml_head'], t('Invalid XML head.'));
  }
}