Subject: | HASHREF type validation allows objects wrongly! |
Date: | Sat, 4 Apr 2015 07:13:10 +0000 |
To: | "bug-Params-Validate [...] rt.cpan.org" <bug-Params-Validate [...] rt.cpan.org> |
From: | "Makudeswaran, Isshwarya" <Isshwarya.M [...] netapp.com> |
Params::Validate type validation doesn't complain on object being passed for an argument whose type is declared to be hashref.
I hope objects are treated differently from hashes for the very reason we have two different datatypes - HASHREF and OBJECT.
Show quoted text
------ code snippet---------------
use Params::Validate qw(validate HASHREF);
use Data::Dumper;
sub invoke_me {
my %opts = validate(@_, {arg => {type => HASHREF}}); # This doesn't complain for objects
print Dumper \%opts;
}
my $obj = Data::Dumper->new([]);
invoke_me(arg => $obj);
------------------------------------------
Perl version: This is perl 5, version 20, subversion 0 (v5.20.0) built for x86_64-linux-thread-multi
Operating system: Linux <some_host> 2.6.32-504.3.3.el6.x86_64 #1 SMP Fri Dec 12 16:05:43 EST 2014 x86_64 x86_64 x86_64 GNU/Linux
Module version: 1.07
The test used XS backend. But I see the same problem with PP variation too (by setting PV_TEST_PERL=1 in ENV)
Thanks,
Isshwarya