Subject: | Params::Validate should work with restricted hashes |
Date: | Tue, 26 Apr 2016 14:41:25 +0200 |
To: | bug-Params-Validate [...] rt.cpan.org |
From: | "Klaus Rindfrey" <k-rindfrey [...] gmx.de> |
Hi,
it would be helpful if Params::Validate accepted restricted hashes as parameter specifications.
I wanted to reuse commonly used parameter specification hashes. To avoid inadvertent changes of these hashes i declared them to be constant using module Const::Fast.
Example (file const.pl attached to this mail):
use strict;
use warnings;
use Const::Fast;
use Params::Validate qw(:all);
const my $scalar_t => {type => SCALAR};
const my $foobar_params => {foo => $scalar_t, bar => $scalar_t};
func(foo => "xxx", bar => 27);
func_pos(42);
sub func {
validate(@_, $foobar_params);
print "func\n";
}
sub func_pos {
validate_pos(@_, $scalar_t);
print "func_pos\n";
}
But this resulted in errors:
Attempt to access disallowed key 'depends' in a restricted hash at /cygdrive/c/inst/Projects/trunk/ReqM2/ReqM2/lib/Params/Validate/PP.pm line 169.
Attempt to access disallowed key 'isa' in a restricted hash at /cygdrive/c/inst/Projects/trunk/ReqM2/ReqM2/lib/Params/Validate/PP.pm line 495.
etc.
Adding some exist() calls in PP.pm resolved the problem (see patch file PP.pm.patch attached to this mail).
Regards,
Klaus
Message body is not shown because sender requested not to inline it.
Message body is not shown because sender requested not to inline it.