Skip Menu |

This queue is for tickets about the Params-Validate CPAN distribution.

Report information
The Basics
Id: 113997
Status: rejected
Priority: 0/
Queue: Params-Validate

People
Owner: Nobody in particular
Requestors: k-rindfrey [...] gmx.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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.

FWIW, this is stalled on someone who wants to dig into the XS and implement this there as well. I'm moving away from Params::Validate to Params::ValidationCompiler for new code (though P::VC may have this same problem, of course).
On Sun Aug 21 18:13:23 2016, DROLSKY wrote: Show quoted text
> FWIW, this is stalled on someone who wants to dig into the XS and > implement this there as well. I'm moving away from Params::Validate to > Params::ValidationCompiler for new code (though P::VC may have this > same problem, of course).
I added some tests and it looks like Params::ValidationCompiler works fine with Const::Fast hashrefs.
On Sun Aug 21 18:17:23 2016, DROLSKY wrote: Show quoted text
> On Sun Aug 21 18:13:23 2016, DROLSKY wrote:
> > FWIW, this is stalled on someone who wants to dig into the XS and > > implement this there as well. I'm moving away from Params::Validate > > to > > Params::ValidationCompiler for new code (though P::VC may have this > > same problem, of course).
> > I added some tests and it looks like Params::ValidationCompiler works > fine with Const::Fast hashrefs.
Then I added some more tests and realized it needs some fixes. a new version of P::VC should be out soon.
I'm no longer going to make any non-bugfix changes to P::V so I'm closing old wishlist tickets. See https://metacpan.org/pod/Params::ValidationCompiler for a better parameter validation tool.