App-MARC-Validator-Report
view release on metacpan or search on metacpan
foreach my $plugin (sort keys %{$self->{'_list'}}) {
if ($self->{'_opts'}->{'p'} eq 'all' || $self->{'_opts'}->{'p'} eq $plugin) {
if (keys %{$self->{'_list'}->{$plugin}} == 0) {
next;
}
print "Plugin '$plugin':\n";
foreach my $error (sort keys %{$self->{'_list'}->{$plugin}}) {
if ($self->{'_opts'}->{'e'} eq 'all' || $self->{'_opts'}->{'e'} eq $error) {
print "- $error\n";
foreach my $id (sort @{$self->{'_list'}->{$plugin}->{$error}}) {
my @err = @{$self->{'_report'}->{$plugin}->{'checks'}->{'not_valid'}->{$id}};
my @structs;
foreach my $err_hr (@err) {
if ($err_hr->{'error'} eq $error) {
push @structs, $err_hr->{'params'};
}
}
my $i = 0;
foreach my $struct_hr (@structs) {
print "-- $id";
foreach my $param_key (sort keys %{$struct_hr}) {
# JSON output.
my $j = Cpanel::JSON::XS->new;
$self->{'_report'} = $j->decode($report);
$self->{'_list'} = {};
foreach my $plugin (keys %{$self->{'_report'}}) {
if (! exists $self->{'_report'}->{$plugin}->{'checks'}) {
print STDERR "Doesn't exist key 'checks' in plugin $plugin.";
return 1;
}
if (! exists $self->{'_report'}->{$plugin}->{'checks'}->{'not_valid'}) {
print STDERR "Doesn't exist key 'checks'->'not_valid' in plugin $plugin.";
return 1;
}
if (! exists $self->{'_list'}->{$plugin}) {
$self->{'_list'}->{$plugin} = {};
}
my $not_valid_hr = $self->{'_report'}->{$plugin}->{'checks'}->{'not_valid'};
foreach my $record_id (keys %{$not_valid_hr}) {
foreach my $error_hr (@{$not_valid_hr->{$record_id}}) {
if (! exists $self->{'_list'}->{$plugin}->{$error_hr->{'error'}}) {
$self->{'_list'}->{$plugin}->{$error_hr->{'error'}} = [$record_id];
} else {
if (none { $_ eq $record_id } @{$self->{'_list'}->{$plugin}->{$error_hr->{'error'}}}) {
push @{$self->{'_list'}->{$plugin}->{$error_hr->{'error'}}}, $record_id;
}
}
}
}
}
t/App-MARC-Validator-Report/04-run.t view on Meta::CPAN
},
$right_ret,
"Process bad report file (not 'checks' structure).",
);
is($exit_code, 1, 'Exit code (1).');
# Test.
@ARGV = (
$data_dir->file('bad_report2.json')->s,
);
$right_ret = "Doesn't exist key 'checks'->'not_valid' in plugin field_008.";
$exit_code = 0;
stderr_is(
sub {
$exit_code = App::MARC::Validator::Report->new->run;
return;
},
$right_ret,
"Process bad report file (not 'checks'->'not_valid' structure).",
);
is($exit_code, 1, 'Exit code (1).');
# Test.
@ARGV = (
'-h',
);
$right_ret = help();
stderr_is(
sub {
t/data/cnb000126664.json view on Meta::CPAN
{
"field_080" : {
"checks" : {
"not_valid" : {
"cnb000126664" : [
{
"error" : "Field 080a has missing '['.",
"params" : {
"value" : "091(437.1)+096(437.1)]:779"
}
},
{
"error" : "Field 080a has missing '['.",
"params" : {
t/data/report1.json view on Meta::CPAN
{
"field_008" : {
"checks" : {
"not_valid" : {}
},
"datetime" : "2025-07-02T20:03:53",
"module_name" : "MARC::Validator::Plugin::Field008",
"module_version" : 0.01,
"name" : "field_008"
},
"field_260" : {
"checks" : {
"not_valid" : {
"cnb001926336" : [
{
"error" : "Bad year in parenthesis in MARC field 260 $c.",
"params" : {
"Value" : "(1933)"
}
}
]
}
},
"datetime" : "2025-07-02T20:03:53",
"module_name" : "MARC::Validator::Plugin::Field260",
"module_version" : 0.01,
"name" : "field_260"
},
"field_264" : {
"checks" : {
"not_valid" : {}
},
"datetime" : "2025-07-02T20:03:53",
"module_name" : "MARC::Validator::Plugin::Field264",
"module_version" : 0.01,
"name" : "field_264"
}
}
( run in 1.414 second using v1.01-cache-2.11-cpan-39bf76dae61 )