NAME
MARC::Moose::Lint::Checker - A Moose::Role to 'lint' biblio record
VERSION
version 1.0.24
DESCRIPTION
A MARC biblio record, MARC21, UNIMARC, whatever, can be validated against rules. By extending this class, you defines your own validation rules. Then the 'lint' object can be given to a MARC::Moose::Record or a MARC::Moose::Reader
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. This role could be applied directly to a MARC::Moose::Record object or to MARC::Moose::Parser object.
SYNOPSYS
package
LintPPN;
use
Moose;
with
'MARC::Moose::Lint::Checker'
sub
check {
my
(
$self
,
$record
) =
@_
;
my
@warnings
= ();
if
(
my
$ppn
=
$record
->field(
'001'
) ) {
if
(
$ppn
->value !~ /^PPN[0-9]*$/ ) {
push
@warning
,
"Invalid PPN in 001 field"
;
}
}
else
{
push
@warning
,
"No 001 field"
;
}
return
@warnings
;
}
package
Main;
# Dump as text all biblio records without valid PPN
my
$reader
=
$MARC::Moose::Reader::File::Iso2709
(
file
=>
'biblio.mrc'
,
parser
=> MARC::Moose::Parser::Iso2709->new(
lint
=> LintPPN->new() ));
while
(
my
$record
=
$reader
->
read
() ) {
if
(
my
@warnings
=
$record
->check() ) {
say
$record
->as(
'Text'
);
}
}
SEE ALSO
AUTHOR
Frédéric Demians <f.demians@tamil.fr>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 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.