You are here

function textimage_preset_edit_validate in Textimage 5.2

Same name and namespace in other branches
  1. 5 textimage.module \textimage_preset_edit_validate()
  2. 6.2 textimage_admin.inc \textimage_preset_edit_validate()
  3. 7.2 textimage.admin.inc \textimage_preset_edit_validate()

File

./textimage_admin.inc, line 533

Code

function textimage_preset_edit_validate($form_id, $form_values) {

  // Check for illegal characters in preset names
  if (preg_match('/[^0-9a-zA-Z_\\-]/', $form_values['name'])) {
    form_set_error('name', t('Please only use alphanumic characters, underscores (_), and hyphens (-) for preset names.'));
  }

  // Check for numbers at beginning of preset names
  if (preg_match('/^[0-9]/', $form_values['name'])) {
    form_set_error('name', t('Preset names can\'t begin with a number.'));
  }

  // Check for duplicate preset names
  $preset = _textimage_preset_load($form_values['name']);
  if ($preset['name'] && (!isset($form_values['pid']) || $form_values['pid'] != $preset['pid'])) {
    form_set_error('name', t('The name %name is already in use by another preset.', array(
      '%name' => $form_values['name'],
    )));
  }
}