NAME
PICA::Schema - Validate PICA based formats with Avram Schemas
SYNOPSIS
$schema = PICA::Schema->new({ ... });
@errors = $schema->check($record);
DESCRIPTION
A PICA Schema defines a set of PICA+ fields and subfields to validate PICA::Data records. Schemas are given as hash reference in Avram Schema language, for instance:
{
fields => {
'021A' => { }, # field without additional information
'003@' => { # field with additional constraints
label => 'Pica-Produktionsnummer',
repeatable => 0,
required => 1,
subfields => {
'0' => { repeatable => 0, required => 1 }
}
}
}
}
See PICA::Schema::Builder to automatically construct schemas from PICA records.
METHODS
check( $record [, %options ] )
Check whether a given PICA::Data record confirms to the schema and return a list of detected violations. Possible options include:
- ignore_unknown_fields
-
Don't report fields not included in the schema.
- ignore_unknown_subfields
-
Don't report subfields not included in the schema.
Errors are given as list of hash reference with keys tag
and occurrence
set to tag and (optional) ocurrence of the violated field. If key repeated
is set, the field was repeated although not repeatable. Otherwise, if key subfields
is set, the field was defined but contained invalid subfields.
Additional error field message
contains a human-readable error message which can also be derived from the rest of the error object.
check_field( $field [, %options ] )
Check whether a PICA field confirms to the schema. Use same options as method check
.
FUNCTION
field_identifier( $field )
Return the field identifier of a given PICA field. The identifier consists of field tag and optional occurrence if the tag starts with 0
.
LIMITATIONS
The current version does not properly validate required field on level 1 and 2.
Field types and subfield order have neither been implemented yet.