/[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 653 by dpavlin, Thu Sep 7 15:57:48 2006 UTC revision 656 by dpavlin, Fri Sep 8 14:13:54 2006 UTC
# Line 145  sub validate_errors { Line 145  sub validate_errors {
145                  $fields->{$f}++;                  $fields->{$f}++;
146    
147                  if ( ! defined($r->{$f}) ) {                  if ( ! defined($r->{$f}) ) {
148                          $errors->{field}->{ $f }->{extra} = "not expected";                          $errors->{field}->{ $f }->{unexpected} = "this field is not expected";
149                          next;                          next;
150                  }                  }
151    
# Line 160  sub validate_errors { Line 160  sub validate_errors {
160                          if (ref($r->{$f}) eq 'ARRAY') {                          if (ref($r->{$f}) eq 'ARRAY') {
161                                  # are values hashes? (has subfields)                                  # are values hashes? (has subfields)
162                                  if (! defined($v)) {                                  if (! defined($v)) {
163                                          $errors->{field}->{$f}->{empty} = undef;  #                                       $errors->{field}->{$f}->{empty} = undef;
164                                          $errors->{dump} = $rec_dump if ($rec_dump);  #                                       $errors->{dump} = $rec_dump if ($rec_dump);
165                                  } elsif (ref($v) ne 'HASH') {                                  } elsif (ref($v) ne 'HASH') {
166                                          $errors->{field}->{$f}->{missing_subfield} = "subfields required for this field";                                          $errors->{field}->{$f}->{missing_subfield} = join(",", @{ $r->{$f} }) . " required";
167                                          next;                                          next;
168                                  } else {                                  } else {
169    
# Line 185  sub validate_errors { Line 185  sub validate_errors {
185                                                                  $sf_repeatable->{$sf}++;                                                                  $sf_repeatable->{$sf}++;
186                                                          };                                                          };
187                                                          if (! first { $_ eq $sf } @{ $r->{$f} }) {                                                          if (! first { $_ eq $sf } @{ $r->{$f} }) {
188                                                                  $errors->{field}->{ $f }->{subfield}->{$sf} = "found extra subfield $sf which shouldn't exist";                                                                  $errors->{field}->{ $f }->{subfield}->{extra}->{$sf}++;
189                                                          }                                                          }
190                                                  }                                                  }
191    
# Line 193  sub validate_errors { Line 193  sub validate_errors {
193                                          if (my @r_sf = sort keys( %$sf_repeatable )) {                                          if (my @r_sf = sort keys( %$sf_repeatable )) {
194    
195                                                  foreach my $sf (@r_sf) {                                                  foreach my $sf (@r_sf) {
196                                                          $errors->{field}->{$f}->{subfield}->{$sf} = "repeatable";                                                          $errors->{field}->{$f}->{subfield}->{extra_repeatable}->{$sf}++;
197                                                          $errors->{field}->{$f}->{dump}->{$f} =                                                          $errors->{field}->{$f}->{dump} =
198                                                                  join('', _pack_subfields_hash( $h, 1 ) );                                                                  join('', _pack_subfields_hash( $h, 1 ) );
199                                                  }                                                  }
200    

Legend:
Removed from v.653  
changed lines
  Added in v.656

  ViewVC Help
Powered by ViewVC 1.1.26