18 |
|
|
19 |
=head1 VERSION |
=head1 VERSION |
20 |
|
|
21 |
Version 0.06 |
Version 0.07 |
22 |
|
|
23 |
=cut |
=cut |
24 |
|
|
25 |
our $VERSION = '0.06'; |
our $VERSION = '0.07'; |
26 |
|
|
27 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
28 |
|
|
203 |
if ( defined( $self->{must_exist_sf}->{$f} ) ) { |
if ( defined( $self->{must_exist_sf}->{$f} ) ) { |
204 |
foreach my $sf (sort keys %{ $self->{must_exist_sf}->{$f} }) { |
foreach my $sf (sort keys %{ $self->{must_exist_sf}->{$f} }) { |
205 |
#warn "====> $f $sf must exist\n"; |
#warn "====> $f $sf must exist\n"; |
206 |
$errors->{field}->{$f}->{subfield}->{$sf} = "missing" |
$errors->{field}->{$f}->{subfield}->{missing}->{$sf}++ |
207 |
unless defined( $subfields->{$sf} ); |
unless defined( $subfields->{$sf} ); |
208 |
} |
} |
209 |
} |
} |
261 |
return $self->{errors}; |
return $self->{errors}; |
262 |
} |
} |
263 |
|
|
264 |
|
=head2 report |
265 |
|
|
266 |
|
Produce nice humanly readable report of errors |
267 |
|
|
268 |
|
print $validate->report; |
269 |
|
|
270 |
|
=cut |
271 |
|
|
272 |
|
sub report { |
273 |
|
my $self = shift; |
274 |
|
|
275 |
|
sub unroll { |
276 |
|
my ($rest,$o, $dump) = @_; |
277 |
|
|
278 |
|
#warn "# rest: $rest o: $o\n"; |
279 |
|
|
280 |
|
return unless ($rest); |
281 |
|
|
282 |
|
if (ref($rest) ne 'HASH') { |
283 |
|
$o .= "($rest)"; |
284 |
|
return ($o,$dump); |
285 |
|
} |
286 |
|
|
287 |
|
foreach my $k (sort keys %{ $rest }) { |
288 |
|
|
289 |
|
if ($k eq 'dump') { |
290 |
|
$dump = $rest->{dump}; |
291 |
|
warn "## dump: $dump\n"; |
292 |
|
next; |
293 |
|
} |
294 |
|
my $u; |
295 |
|
($u, $dump) = unroll($rest->{$k}, $o, $dump); |
296 |
|
$o .= "$k $u"; |
297 |
|
|
298 |
|
|
299 |
|
} |
300 |
|
return ($o,$dump); |
301 |
|
} |
302 |
|
|
303 |
|
my $out = ''; |
304 |
|
|
305 |
|
foreach my $mfn (sort keys %{ $self->{errors} }) { |
306 |
|
my ($msg,$dump) = unroll( $self->{errors}->{$mfn}, '', '' ); |
307 |
|
$out .= "MFN $mfn\n$msg\t$dump\n\n"; |
308 |
|
} |
309 |
|
|
310 |
|
return $out; |
311 |
|
} |
312 |
|
|
313 |
=head1 AUTHOR |
=head1 AUTHOR |
314 |
|
|
315 |
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >> |
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >> |