You are here

function mediafront_validate_preset_name in MediaFront 7

Same name and namespace in other branches
  1. 6.2 includes/mediafront.preset.inc \mediafront_validate_preset_name()
  2. 6 includes/mediafront.preset.inc \mediafront_validate_preset_name()
  3. 7.2 includes/mediafront.preset.inc \mediafront_validate_preset_name()

Verify the syntax of the given prefix name.

Borrowed from the user.module. :)

2 calls to mediafront_validate_preset_name()
mediafront_create_preset_validate in includes/mediafront.preset.inc
Validation for the preset form.
mediafront_preset_import_validate in includes/mediafront.preset.inc
Validation for the preset import form.

File

includes/mediafront.preset.inc, line 650

Code

function mediafront_validate_preset_name($name) {
  if (!$name) {
    return t('You must enter a preset.');
  }
  if (mediafront_preset_name_exists($name)) {
    return t('The preset name %name is already taken.', array(
      '%name' => $name,
    ));
  }
  if (strpos($name, ' ') !== FALSE) {
    return t('The preset name cannot contain a space.');
  }
  if (is_numeric($name[0])) {
    return t('The preset name cannot begin with a number.');
  }
  if (preg_match('/[^a-z0-9_]/i', $name)) {
    return t('The preset name contains an illegal character.');
  }
  if (drupal_strlen($name) > MEDIAFRONT_PRESET_MAX_LENGTH) {
    return t('The preset name %name is too long: it must be %max characters or less.', array(
      '%name' => $name,
      '%max' => MEDIAFRONT_PRESET_MAX_LENGTH,
    ));
  }
}