Jump to content
Wiki Home
EPrints Home
Bazaar
Files
Main menu
Main menu
move to sidebar
hide
Navigation
Front Page
EPrints 3 Manual
EPrints Training Course
EPrints Glossary
Installing EPrints
How-to Configure EPrints
EPrints 3.2+ API
EPrints 3 Reference
EPrints Plugins
Wiki
All categories
Recent changes
Main Page
Help
EPrints Documentation
Search
Search
Appearance
Log in
Request account
Personal tools
Log in
Request account
Pages for logged out editors
learn more
Contributions
Talk
Editing
Document validate.pl
Page
Discussion
British English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{dirs}} {{cfgd}} '''document_validate.pl''' contains configuration for validating Document data objects. The '''validate_document''' function tests the validity of the values set for the metadata fields for a Document. This usually happens when a user submits the form (e.g. clicks on ''Previous'', ''Save and Return'' or ''Next'') on the ''Upload'' stage. * '''<tt>$document</tt>''' is the [[API:EPrints/DataObj/Document|Document]] object being validated. * '''<tt>$repository</tt>''' is a [[API:EPrints/Repository|Repository]] object. * '''<tt>$for_archive</tt>''' is a boolean indicating whether the current validation is a precursor to the item being moved to the live archive. Its value make no difference for the default '''validate_document''' function. == Example == In this example, the document is checked to validate: # ''formatdesc'' is set if the ''format'' is set to ''other''. # ''security'' is not ''public'' if ''embargo_date'' is set or the document is not really emabargoed. # A full ''embargo_date'' is set to ensure there is no ambiguity about when an embargo will be lifted. # The ''embargo_date'' is set in the future. <pre> $c->{validate_document} = sub { my( $document, $repository, $for_archive ) = @_; my @problems = (); my $xml = $repository->xml(); # CHECKS IN HERE # "other" documents must have a description set if( $document->value( "format" ) eq "other" && !EPrints::Utils::is_set( $document->value( "formatdesc" ) ) ) { my $fieldname = $xml->create_element( "span", class=>"ep_problem_field:documents" ); push @problems, $repository->html_phrase( "validate:need_description" , type=>$document->render_citation("brief"), fieldname=>$fieldname ); } # security can't be "public" if date embargo set if( $document->value( "security" ) eq "public" && EPrints::Utils::is_set( $document->value( "date_embargo" ) ) ) { my $fieldname = $xml->create_element( "span", class=>"ep_problem_field:documents" ); push @problems, $repository->html_phrase( "validate:embargo_check_security" , fieldname=>$fieldname ); } # embargo expiry date must be a full year, month and day and must be in the future if( EPrints::Utils::is_set( $document->value( "date_embargo" ) ) ) { my $value = $document->value( "date_embargo" ); my ($year, $month, $day) = split( '-', $value ); if ( !EPrints::Utils::is_set( $month ) || !EPrints::Utils::is_set( $day ) ) { my $fieldname = $xml->create_element( "span", class=>"ep_problem_field:documents" ); push @problems, $repository->html_phrase( "validate:embargo_incomplete_date", fieldname=>$fieldname ); } else { my ($thisyear, $thismonth, $thisday) = EPrints::Time::get_date_array(); if( $year < $thisyear || ( $year == $thisyear && $month < $thismonth ) || ( $year == $thisyear && $month == $thismonth && $day <= $thisday ) ) { my $fieldname = $xml->create_element( "span", class=>"ep_problem_field:documents" ); push @problems, $repository->html_phrase( "validate:embargo_invalid_date", fieldname=>$fieldname ); } } } return( @problems ); };</pre>
Summary:
Please note that all contributions to EPrints Documentation may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
EPrints Documentation:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Cfgd
(
edit
)
Template:Dirs
(
edit
)
Template:RefLinks
(
edit
)