https://wiki.eprints.org/w/index.php?title=Eprint_validate.pl&feed=atom&action=historyEprint validate.pl - Revision history2024-03-28T09:07:09ZRevision history for this page on the wikiMediaWiki 1.31.8https://wiki.eprints.org/w/index.php?title=Eprint_validate.pl&diff=14273&oldid=prevDrn@ecs.soton.ac.uk: Added page about config file2022-01-22T22:56:52Z<p>Added page about config file</p>
<p><b>New page</b></p><div>{{dirs}}<br />
{{cfgd}}<br />
<br />
This file contains configuration for validating EPrint data objects.<br />
<br />
The '''validate_eprint''' function tests the validity of the values set for the metadata fields for an EPrint. This usually happens when a user reaches the '''Deposit''' stage of the EPrint workflow.<br />
* '''<tt>$eprint</tt>''' is the [[API:EPrints/DataObj/EPrint|EPrint]] object being validated.<br />
* '''<tt>$repository</tt>''' is a [[API:EPrints/Repository|Repository]] object.<br />
* '''<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.<br />
<br />
'''Example'''<br />
In this example, the eprint is checked to validate that at least one creator or editor is set.<br />
<pre><br />
$c->{validate_eprint} = sub<br />
{<br />
my( $eprint, $repository, $for_archive ) = @_;<br />
<br />
my $xml = $repository->xml();<br />
<br />
my @problems = ();<br />
<br />
# If we don't have creators (eg. for a book) then we<br />
# must have editor(s). To disable that rule, remove the<br />
# following block.<br />
if( !$eprint->is_set( "creators" ) &&<br />
!$eprint->is_set( "editors" ) )<br />
{<br />
my $fieldname = $xml->create_element( "span", class=>"ep_problem_field:creators" );<br />
push @problems, $repository->html_phrase(<br />
"validate:need_creators_or_editors",<br />
fieldname=>$fieldname );<br />
}<br />
<br />
return( @problems );<br />
};<br />
</pre><br />
<br />
The '''skip_validation''' function is commented out by default but can be uncommented and used to define logic for EPrint data objects that should not be validated. This is mainly for when you may be doing a mass import of legacy data that may not have values for certain fields, as they were not historically required.</div>Drn@ecs.soton.ac.uk