From fb50f1674279bd486e03ce08b05011ea8f78ced1 Mon Sep 17 00:00:00 2001 From: "git@daemon.de" Date: Tue, 2 Dec 2014 08:04:21 +0100 Subject: [PATCH] fixed cached errors bug --- Changelog | 10 ++++++++-- Struct.pm | 8 +++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index 0f24320..f6b5696 100644 --- a/Changelog +++ b/Changelog @@ -1,7 +1,13 @@ -NEXT +0.9 o Added AUTHOR, LICENSE and ABSTRACT fields to 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 o applied patches by Per Carlson: - don't die on 1st error, rather collect them and @@ -39,7 +45,7 @@ NEXT o well, against renamed it to Data::Validate::Struct, 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. diff --git a/Struct.pm b/Struct.pm index eb77bfe..0f2dd13 100644 --- a/Struct.pm +++ b/Struct.pm @@ -21,7 +21,7 @@ use File::stat; use Data::Validate qw(:math is_printable); use Data::Validate::IP qw(is_ipv4 is_ipv6); -our $VERSION = 0.08; +our $VERSION = 0.09; use vars qw(@ISA); @@ -128,7 +128,6 @@ sub new { # types from here and use Data::Validate's methods as subroutine # checks, which we already support. $self->{types} = \%__ValidatorTypes; - $self->{debug} = 0; $self->{errors} = []; @@ -175,6 +174,9 @@ sub type { sub validate { my ($self, $config) = @_; + # reset errors in case it's a repeated run + $self->{errors} = []; + $self->_traverse($self->{structure}, $config, ()); # return TRUE if no errors return scalar @{ $self->{errors} } == 0; @@ -884,7 +886,7 @@ Thanks to David Cantrell for his helpful hints. =head1 VERSION -0.08 +0.09 =cut