Subject: | ValidateXS should validate that data is defined before use |
When using Params::ValidateXS with warnings enabled and param is validated that has the value of undef, then you get the following warning:
Use of uninitialized value in pattern match (m//) at /usr/local/lib/perl/5.8.4/Params/ValidateXS.pm line 52.
instead of:
sub _check_regex_from_xs { return $_[0] =~ /$_[1]/ ? 1 : 0 }
Perhaps this:
sub _check_regex_from_xs { return 0 if !defined($_[0]); return $_[0] =~ /$_[1]/ ? 1 : 0 }
example for testing, before patch regex warnings. after patch, no warnings. Still fails to validate.
use warnings;
my @a = ( foo => undef);
validate( @a, { foo => { regex => qr/^bar/ , optional => 1}, } );