The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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 sample records.

Schema information can be included in PICA XML 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::Schema::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.

ignore_subfield_order

Don't report errors resulting on wrong subfield order.

ignore_subfields

Don't check subfields at all.

check_field( $field [, %options ] )

Check whether a PICA field confirms to the schema. Use same options as method check. Returns a PICA::Schema::Error on schema violation.

FUNCTIONS

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.

check_value( $value, $schedule [, %options ] )

Check a subfield value against a subfield schedule. On malformed values returns a subfield error without message key.

LIMITATIONS

The current version does not properly validate required field on level 1 and 2.

Field types have neither been implemented yet.

SEE ALSO

PICA::Path

MARC::Schema

MARC::Lint