You are here

function pagerer_preset_name_validate in Pagerer 7

Preset name validation.

1 string reference to 'pagerer_preset_name_validate'
pagerer_preset_add_form in ./pagerer.admin.inc
Preset add form.

File

./pagerer.admin.inc, line 364
Pagerer administration

Code

function pagerer_preset_name_validate($element, $form_state) {

  // 'core' preset name is reserved.
  if ($element['#value'] == 'core') {
    form_set_error($element['#name'], t("The preset name 'core' is reserved for internal use."));
  }

  // Check for duplicates.
  $list = _pagerer_list_presets();
  if (isset($list[$element['#value']])) {
    form_set_error($element['#name'], t('The preset name %name is already in use.', array(
      '%name' => $element['#value'],
    )));
  }

  // Check for illegal characters in preset names.
  if (preg_match('/[^0-9a-z_\\-]/', $element['#value'])) {
    form_set_error($element['#name'], t('Please only use lowercase alphanumeric characters, underscores (_), and hyphens (-) for preset names.'));
  }
}