PICA::Schema(3)

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 <https://format.gbv.de/schema/avram/specification>, 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 sample records.

Schema information can also be used for documentation of records with PICA::Writer::XML.

METHODS

  check( $record [, %options ] )
Check whether a given PICA::Data record confirms to the schema and return a list of PICA::Error. 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.

ignore_unknown
    Don't report fields and subfields not included in the schema.

allow_deprecated_fields
    Don't report deprecated fields.

allow_deprecated_subfields
    Don't report deprecated subfields.

allow_deprecated_codes
    Don't report deprecated codes.

allow_deprecated
    Don't report deprecated fields, subfields, and codes.

allow_empty_subfields
    Don't report subfields with empty string values.

ignore_subfield_order
    Don't report errors resulting on wrong subfield order.

ignore_subfields
    Don't check subfields at all.

check_annotation
    Require or forbid annotated fields if set to true or false. Otherwise just check whether given annotation is a valid character.

  check_field( $field [, %options ] )
Check whether a PICA field confirms to the schema. Use same options as method "check". Returns a PICA::Error on schema violation.

  abbreviated
Return an abbreviated data structure of the schema without inferable and calculated fields such as "tag", "occurrence", "code", "total" and "records".

FUNCTIONS

  clean_pica( $record[, %options] )
Syntactically check a PICA record and return it as array of arrays on success. Syntactic check is performed on schema validation before checking the record against a schema and before writing a record.

Options include:

error
    Error handler, prints instances of PICA::Error to STDERR by default. Use "undef" to ignore all errors.

ignore_empty_records
    Don't emit an error if the record has no fields.

ignore_subfields
    Don't check subfields.

  field_identifier( [$schema, ] $field )
Return the field identifier of a given PICA field. The identifier consists of field tag and optional occurrence. If this function is used as method of a schema, the field_identifier may contain an occurrence ranges instead of the plain occurrence.

  check_value( $value, $schedule [, %options ] )
Check a subfield value against a subfield schedule. On malformed values returns a subfield error without "message" key.

  check_pattern( $value, $pattern )
Check a value against a pattern and return an error on failure.

LIMITATIONS
Fields types and deprecated (sub)fields in Avram Schemas are not fully supported yet.

SEE ALSO
PICA::Path

MARC::Schema

MARC::Lint