You are here

function _migrate_content_set_validate in Migrate 6

Common validation function for content sets

2 calls to _migrate_content_set_validate()
migrate_content_set_mappings_validate in ./migrate_pages.inc
Implementation of hook_validate().
_migrate_content_set_form_validate in ./migrate_pages.inc
Implementation of hook_validate().

File

./migrate_pages.inc, line 411

Code

function _migrate_content_set_validate($form_state) {
  $machine_name = trim($form_state['values']['machine_name']);
  if (!$machine_name) {
    form_set_error('machine_name', t('Content set name is required'));
  }
  else {
    $mcsid = db_result(db_query("SELECT mcsid FROM {migrate_content_sets}\n                                 WHERE machine_name='%s'", $machine_name));
    if ($mcsid && $mcsid != $form_state['values']['mcsid']) {
      form_set_error('machine_name', t('The content set name must be unique.'));
    }
    else {
      if (preg_match('/[^a-zA-Z0-9_]/', $machine_name)) {
        form_set_error('machine_name', t('Content set name must be alphanumeric or underscores only.'));
      }
    }
  }
  $description = trim($form_state['values']['description']);
  if (!$description) {
    form_set_error('description', t('Content set description is required'));
  }
  $weight = trim($form_state['values']['weight']);
  if (!is_numeric($weight) || (int) $weight != $weight) {
    form_set_error('weight', t('Weight must be an integer value (positive or negative)'));
  }
}