Eprint validate.pl

From EPrints Documentation
Jump to: navigation, search

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects

Back to cfg.d

This file contains configuration for validating EPrint data objects.

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.

  • $eprint is the EPrint object being validated.
  • $repository is a Repository object.
  • $for_archive 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 eprint is checked to validate that at least one creator or editor is set.

$c->{validate_eprint} = sub
    my( $eprint, $repository, $for_archive ) = @_;
    my $xml = $repository->xml();
    my @problems = ();
    # If we don't have creators (eg. for a book) then we
    # must have editor(s). To disable that rule, remove the
    # following block.
    if( !$eprint->is_set( "creators" ) &&
        !$eprint->is_set( "editors" ) )
        my $fieldname = $xml->create_element( "span", class=>"ep_problem_field:creators" );
        push @problems, $repository->html_phrase(
                fieldname=>$fieldname );
    return( @problems );

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.