/[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 515 by dpavlin, Tue May 16 15:23:05 2006 UTC revision 516 by dpavlin, Tue May 16 15:23:12 2006 UTC
# Line 69  sub new { Line 69  sub new {
69    
70          foreach my $l (split(/[\n\r]+/, $v_file)) {          foreach my $l (split(/[\n\r]+/, $v_file)) {
71                  $curr_line++;                  $curr_line++;
72                  # skip comments  
73                  next if ($l =~ m/^#/);                  # skip comments and whitespaces
74                    next if ($l =~ /^#/ || $l =~ /^\s*$/);
75    
76                  $l =~ s/^\s+//;                  $l =~ s/^\s+//;
77                  $l =~ s/\s+$//;                  $l =~ s/\s+$//;
78    
79                  my @d = split(/\s+/, $l);                  my @d = split(/\s+/, $l);
80    
81                  my $fld = shift @d || $log->logdie("need field name in line $curr_line: $l");                  my $fld = shift @d;
82    
83                    $log->logdie("need field name in line $curr_line: $l") unless (defined($fld));
84    
85                  if (@d) {                  if (@d) {
86                          $v->{$fld} = \@d;                          $v->{$fld} = \@d;
# Line 91  sub new { Line 94  sub new {
94    
95          $self->{rules} = $v;          $self->{rules} = $v;
96    
97            $log->info("validation uses rules from $self->{path}");
98    
99          $self ? return $self : return undef;          $self ? return $self : return undef;
100  }  }
101    
# Line 118  sub validate_errors { Line 123  sub validate_errors {
123    
124          foreach my $f (keys %{ $rec }) {          foreach my $f (keys %{ $rec }) {
125    
126                  next if (!defined($f) || $f eq '');                  next if (!defined($f) || $f eq '' || $f eq '000');
127    
128                  if (! defined($r->{$f})) {                  if (! defined($r->{$f})) {
129                          push @errors, "field '$f' shouldn't exists";                          push @errors, "field '$f' shouldn't exists";

Legend:
Removed from v.515  
changed lines
  Added in v.516

  ViewVC Help
Powered by ViewVC 1.1.26