taxonomy_form_vocabulary_validate($form, &$form_state)Validation handler for the vocabulary form.
modules/taxonomy/taxonomy.admin.inc, line 170
<?php
function taxonomy_form_vocabulary_validate($form, &$form_state) {
if ($form_state['clicked_button']['#value'] != t('Delete') && isset($form_state['values']['machine_name'])) {
// Restrict machine names to appropriate characters.
$machine_name = $form_state['values']['machine_name'];
if (!preg_match('!^[a-z0-9_]+$!', $form_state['values']['machine_name'])) {
form_set_error('machine_name', t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
}
// Restrict machine names to 21 characters to avoid exceeding the limit
// for field names.
if (drupal_strlen($machine_name) > 21) {
form_set_error('machine_name', t('The machine-readable name must not exceed 21 characters.'));
}
// Do not allow duplicate machine names.
$vocabularies = taxonomy_get_vocabularies();
foreach ($vocabularies as $vocabulary) {
if ($machine_name == $vocabulary->machine_name && (!isset($form_state['values']['vid']) || $vocabulary->vid != $form_state['values']['vid'])) {
form_set_error('machine_name', t('This machine-readable name is already in use by another vocabulary and must be unique.'));
}
}
}
}
?>