/[webpac2]/trunk/lib/WebPAC/Validate.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Validate.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 642 by dpavlin, Wed Sep 6 19:52:36 2006 UTC revision 643 by dpavlin, Wed Sep 6 21:10:30 2006 UTC
# Line 9  use base 'WebPAC::Common'; Line 9  use base 'WebPAC::Common';
9  use File::Slurp;  use File::Slurp;
10  use List::Util qw/first/;  use List::Util qw/first/;
11  use Data::Dumper;  use Data::Dumper;
12    use WebPAC::Normalize qw/_pack_subfields_hash/;
13    use Storable qw/dclone/;
14    
15  =head1 NAME  =head1 NAME
16    
# Line 16  WebPAC::Validate - provide simple valida Line 18  WebPAC::Validate - provide simple valida
18    
19  =head1 VERSION  =head1 VERSION
20    
21  Version 0.01  Version 0.02
22    
23  =cut  =cut
24    
25  our $VERSION = '0.01';  our $VERSION = '0.02';
26    
27  =head1 SYNOPSIS  =head1 SYNOPSIS
28    
# Line 45  configuration file in following format: Line 47  configuration file in following format:
47  Create new validation object  Create new validation object
48    
49    my $validate = new WebPAC::Validate(    my $validate = new WebPAC::Validate(
50          path => '/path/to/input/validate_file',          path => 'conf/validate/file',
51    );    );
52    
53  =cut  =cut
# Line 143  sub validate_errors { Line 145  sub validate_errors {
145                                          push @errors, "$f has value without subfields: $v";                                          push @errors, "$f has value without subfields: $v";
146                                          next;                                          next;
147                                  } else {                                  } else {
148    
149                                            my $h = dclone( $v );
150    
151                                            delete($v->{subfields}) if (defined($v->{subfields}));
152    
153                                          foreach my $sf (keys %{ $v }) {                                          foreach my $sf (keys %{ $v }) {
154    
155                                                  # permited subfield?                                                  # permited subfield?
156                                                  if (! first { $_ eq $sf } @{ $r->{$f} }) {                                                  if (! first { $_ eq $sf } @{ $r->{$f} }) {
157                                                          push @errors, "$f has unknown subfield: $sf" if ($sf ne 'subfields');                                                          push @errors, "$f has unknown subfield: $sf";
158                                                    }
159    
160                                                    # is repeatable?
161                                                    if ( ref($v->{$sf}) eq 'ARRAY' ) {
162                                                            push @errors, "$f subfield $sf is repeatable: " .
163                                                                    join('', _pack_subfields_hash( dclone($h), 1) );
164                                                            ### FIXME
165                                                  }                                                  }
166                                          }                                          }
167                                  }                                  }

Legend:
Removed from v.642  
changed lines
  Added in v.643

  ViewVC Help
Powered by ViewVC 1.1.26