MARC::Moose::Lint::Checker - A Moose::Role to 'lint' biblio record
version 1.0.46
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
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.
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; use MARC::Moose::Reader::File::Iso2709; use MARC::Moose::Parser::Iso2709; # 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'); } }
MARC::Moose
MARC::Moose::Lint::Checker::RulesFile
MARC::Moose::Lint::Processor
Frédéric Demians <f.demians@tamil.fr>
This software is copyright (c) 2022 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.
To install MARC::Moose, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MARC::Moose
CPAN shell
perl -MCPAN -e shell install MARC::Moose
For more information on module installation, please visit the detailed CPAN module installation guide.