diff --git a/Changelog b/Changelog index f6b5696..f031984 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,10 @@ -0.9 +0.10 + o fixed RT#101884 + - _trim() only removed 1st whitespace + - optional checks were ineffective if the value was undef +0.09 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 diff --git a/README b/README index 7d597c3..261430a 100644 --- a/README +++ b/README @@ -434,7 +434,7 @@ SEE ALSO Data::Validate::IP common data validation methods for IP-addresses. LICENSE AND COPYRIGHT - Copyright (c) 2007-2014 T. v.Dein + Copyright (c) 2007-2015 T. v.Dein This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. @@ -469,5 +469,5 @@ AUTHORS Thanks to David Cantrell for his helpful hints. VERSION - 0.08 + 0.10 diff --git a/Struct.pm b/Struct.pm index 0f2dd13..10ef1fd 100644 --- a/Struct.pm +++ b/Struct.pm @@ -1,5 +1,5 @@ # -# Copyright (c) 2007-2014 T. v.Dein . +# Copyright (c) 2007-2015 T. v.Dein . # All Rights Reserved. Std. disclaimer applies. # Artistic License, same as perl itself. Have fun. # @@ -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.09; +our $VERSION = 0.10; use vars qw(@ISA); @@ -251,6 +251,19 @@ sub _check_type { # the value in $hash->{$key} (shortcut) my $value = $hash->{$key}; + # is the value checkable? + unless (defined $value) { + if (grep { $_ eq 'optional' } @types) { + # do nothing + $self->_debug("$key is optional"); + return; + } + else { + # report error + return "value of '$key' is undef"; + } + } + # the aggregated match over *all* types my $match = 0; foreach my $type (@types) { @@ -301,7 +314,7 @@ sub _check_type { sub _trim { my @a = @_; foreach (@a) { - s/^\s+|\s+$//; + s/^\s+|\s+$//g; } return wantarray ? @a : $a[0]; } @@ -846,7 +859,7 @@ L common data validation methods for IP-addresses. =head1 LICENSE AND COPYRIGHT -Copyright (c) 2007-2014 T. v.Dein +Copyright (c) 2007-2015 T. v.Dein This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. @@ -886,7 +899,7 @@ Thanks to David Cantrell for his helpful hints. =head1 VERSION -0.09 +0.10 =cut