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

NAME

MARC::Moose::Lint::Checker - A class to 'lint' biblio record based on a rules file

VERSION

version 1.0.12

ATTRIBUTES

file

Name of the file containing validation rules based on which a biblio record can be validated.

METHODS

check( record )

This method checks a biblio record, based on the current 'lint' object. The biblio record is a MARC::Moose::Record object. An array of validation errors/warnings is returned. Those errors are just plain text explanation on the reasons why the record doesn't comply with validation rules.

SYNOPSYS

 use MARC::Moose::Record;
 use MARC::Moose::Reader::File::Iso2709;
 use MARC::Moose::Lint::Checker;

 # Read an ISO2709 file, and dump found errors
 my $reader = MARC::Moose::Reader::File::Iso2709->new(
     file => 'biblio.mrc' );
 my $lint = MARC::Moose::Lint::Checker->new(
     file => 'unimarc.rules' );
 while ( my $record = $reader->read() ) {
     if ( my @result = $lint->check($record) ) {
         say "Biblio record #", $record->field('001')->value;
         say join("\n", @result), "\n";
     }
 }

VALIDATION RULES

Validation rules are defined in a textual form. The file is composed of two parts: (1) field rules, (2) validation tables.

(1) Field rules define validation rules for each tag. A blank line separates tags. For example:

 102+
 #
 #
 abc+i@CTRY ^[a-z]{3}$
 2+

Line 1 contains the field tag. If a + is present, the field is repeatable. If a _ is present, the field is mandatory. For control fields (tag under 010), an optional second line can contain a regular expression on which validating field content. For <standard fields>, line 2 and 3 contains a regular expression on which indicators 1 and 2 are validated. # means a blank indicator. Line 4 and the following define rules for validating subfields. A first part contains subfield's letters, and + (repeatable) and/or _ (mandatory), followed by an optional validation table name begining with @. A blank separates the first part from the second part. The second part contains a regular expression on which subfield content is validated.

(2) Validation tables part of the file allow to define several validation tables. The table name begins with ==== TABLE NAME in uppercase. Then each line is a code in the validation table.

This is for example, a simplified standard UNIMARC validation rules file:

 005
 \d{14}\.\d

 100_
 #
 #
 a ^[0-9]{8}[a-ku][0-9 ]{8}[abcdeklu ]{3}[a-huyz][01 ][a-z]{3}[a-cy][01|02|03|04|05|06|07|08|09|10|11|50]{2}

 101_
 0|1|2
 #
 abcdfghij+@LANG ^[a-z]{3}$

 200_
 0|1
 #
 a_+
 bcdefghi+
 v
 z5+

 ==== CTRY
 AF
 AL
 DZ
 GG
 GN
 GW
 GY
 HT
 HM
 VE
 VN
 VG
 VI
 ZM
 ZW
 
 ==== LANG
 aar
 afh
 afr
 afa
 ain
 aka
 akk

SEE ALSO

AUTHOR

Frédéric Demians <f.demians@tamil.fr>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Frédéric Demians.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.