You are here

function video_validate_preset_name in Video 7.2

Same name and namespace in other branches
  1. 7 modules/video_ui/video.preset.inc \video_validate_preset_name()

Verify the syntax of the given prefix name.

Borrowed from the user.module. :)

2 calls to video_validate_preset_name()
video_preset_import_validate in modules/video_ui/video.preset.inc
Validation for the preset import form.
_video_preset_name_validate in modules/video_ui/video.preset.inc
Validation for the preset form.

File

modules/video_ui/video.preset.inc, line 912
Administrative interface for maintaining video presets.

Code

function video_validate_preset_name($name, $old_name = '') {
  if (empty($name)) {
    return t('You must enter a preset.');
  }
  if (strnatcasecmp($name, $old_name) != 0 && video_preset_name_exists($name)) {
    return t('The preset name %name is already taken.', array(
      '%name' => $name,
    ));
  }
  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) > VIDEO_PRESET_MAX_LENGTH) {
    return t('The preset name %name is too long: it must be %max characters or less.', array(
      '%name' => $name,
      '%max' => VIDEO_PRESET_MAX_LENGTH,
    ));
  }
  return NULL;
}