function biblio_validate in Bibliography Module 5
Implementation of hook_validate().
Errors should be signaled with form_set_error().
File
- ./
biblio.module, line 1732
Code
function biblio_validate(&$node) {
if ($node->biblio_type == 0) {
form_set_error('biblio_type', t('You must select the type of publication'));
return;
}
if (!$node->biblio_authors) {
form_set_error('biblio_authors', t('You must supply at least one author name'));
}
/* if (!strstr("$node->biblio_authors", ";")) {
form_set_error('biblio_authors', t('You must separate the author names with semicolons'));
}
*/
if (!isset($node->biblio_year)) {
form_set_error('biblio_year', t('You must supply the year of publication'));
}
if (!is_numeric($node->biblio_year) && $node->biblio_year != t("In Press") && $node->biblio_year != t("Submitted")) {
form_set_error('biblio_year', t('Year of Publication must be a number between 1 and @thisyear or the words "In Press" or "Submitted" ', array(
'@thisyear' => $today['year'] + 1,
)));
}
$today = getdate();
if (is_numeric($node->biblio_year) && ($node->biblio_year < 1 || $node->biblio_year > $today['year'] + 1)) {
form_set_error('biblio_year', t('Year of Publication must be a number between 1 and @thisyear', array(
'@thisyear' => $today['year'],
)));
}
/* if (!$node->biblio_secondary_title) {
form_set_error('biblio_secondary_title', t('You must supply the Journal Title, Conference Name or Book Title'));
}
*/
}