| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::Exception; |
| 4 |
use Test::More; |
| 5 |
|
| 6 |
use Catmandu::Importer::MARC; |
| 7 |
use Catmandu::Validator::MARC; |
| 8 |
use Catmandu qw(importer); |
| 9 |
|
| 10 |
require_ok( 'Catmandu::Validator::MARC' ); |
| 11 |
can_ok('Catmandu::Validator::MARC', ('validate_data')); |
| 12 |
# load default MARC schema |
| 13 |
my $validator = Catmandu::Validator::MARC->new(); |
| 14 |
|
| 15 |
my $importer = Catmandu::Importer::MARC->new( |
| 16 |
file => 't/camel.mrc', |
| 17 |
type => "ISO" |
| 18 |
); |
| 19 |
|
| 20 |
my @errors; |
| 21 |
$importer->each( sub { |
| 22 |
my $record = shift; |
| 23 |
unless($validator->validate($record)){ |
| 24 |
push @errors, $_ for @{$validator->last_errors()}; |
| 25 |
} |
| 26 |
}); |
| 27 |
|
| 28 |
is (@errors, 1, 'got one error'); |
| 29 |
is ($errors[0]->{tag}, 100, 'error in field 100'); |
| 30 |
|
| 31 |
done_testing; |