fixed cached errors bug

This commit is contained in:
git@daemon.de
2014-12-02 08:04:21 +01:00
parent 5025224c3d
commit fb50f16742
2 changed files with 13 additions and 5 deletions

View File

@@ -1,7 +1,13 @@
NEXT 0.9
o Added AUTHOR, LICENSE and ABSTRACT fields to Makefile.PL o Added AUTHOR, LICENSE and ABSTRACT fields to Makefile.PL
o Fixed 'Artistic' typo in Makefile.PL o Fixed 'Artistic' typo in Makefile.PL
o fixed cached errors bug - if a validator object has
been used multiple times and if during the first
run some errors occured, subsequent runs would show
the same error again and again.
0.08 0.08
o applied patches by Per Carlson: o applied patches by Per Carlson:
- don't die on 1st error, rather collect them and - don't die on 1st error, rather collect them and
@@ -39,7 +45,7 @@ NEXT
o well, against renamed it to Data::Validate::Struct, o well, against renamed it to Data::Validate::Struct,
because Data::Validate already exists. because Data::Validate already exists.
o removed chack for 'resolvablehost' because some cpantesters o removed check for 'resolvablehost' because some cpantesters
failed to run it. failed to run it.

View File

@@ -21,7 +21,7 @@ use File::stat;
use Data::Validate qw(:math is_printable); use Data::Validate qw(:math is_printable);
use Data::Validate::IP qw(is_ipv4 is_ipv6); use Data::Validate::IP qw(is_ipv4 is_ipv6);
our $VERSION = 0.08; our $VERSION = 0.09;
use vars qw(@ISA); use vars qw(@ISA);
@@ -128,7 +128,6 @@ sub new {
# types from here and use Data::Validate's methods as subroutine # types from here and use Data::Validate's methods as subroutine
# checks, which we already support. # checks, which we already support.
$self->{types} = \%__ValidatorTypes; $self->{types} = \%__ValidatorTypes;
$self->{debug} = 0; $self->{debug} = 0;
$self->{errors} = []; $self->{errors} = [];
@@ -175,6 +174,9 @@ sub type {
sub validate { sub validate {
my ($self, $config) = @_; my ($self, $config) = @_;
# reset errors in case it's a repeated run
$self->{errors} = [];
$self->_traverse($self->{structure}, $config, ()); $self->_traverse($self->{structure}, $config, ());
# return TRUE if no errors # return TRUE if no errors
return scalar @{ $self->{errors} } == 0; return scalar @{ $self->{errors} } == 0;
@@ -884,7 +886,7 @@ Thanks to David Cantrell for his helpful hints.
=head1 VERSION =head1 VERSION
0.08 0.09
=cut =cut