Skip Menu |

This queue is for tickets about the Module-Optional CPAN distribution.

Report information
The Basics
Id: 21389
Status: resolved
Priority: 0/
Queue: Module-Optional

People
Owner: Nobody in particular
Requestors: STEFFENW [...] cpan.org
Cc:
AdminCc:

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



Default setting doesn't working and so it is not an alternative for Params::Validate in productive Systems. Also the package is named Params::Validate::Dummy and not Params::Validate. Maybe I can't understand the howto of this module, then excuse me. Params::Validate::Dummy ':all'; sub mysub { my ($scalar, $hashref) = validate_pos( @_, {type => SCALAR}, {type => HASHREF} ); %$hashref = validate_with( params => $hashref, spec => { key => { type => SCALAR, }, key_optional => { type => SCALAR, optional => 1, default => 'default value for optialal key', }, }, called => '2nd Parameter hashref', ); return $hashref->{key_optional}; } # return value is now undef and not 'default value for optialal key' like Params::Validate.
From: IVORW [...] cpan.org
On Fri Sep 08 05:33:51 2006, STEFFENW wrote: Show quoted text
> Default setting doesn't working and so it is not an alternative for > Params::Validate in productive Systems. Also the package is named > Params::Validate::Dummy and not Params::Validate. > > Maybe I can't understand the howto of this module, then excuse me.
Thank you for pointing out that the documentation is not clear about how this module is intended to be used. I will revise the pod, and the next version will hopefully make this clearer. The whole idea of the shipped *::Dummy with Module::Optional is that it does NOTHING. The current version of the module doesn't implement defaulting - you'll either have to insist on the real Params::Validate, or do the defaulting yourself after calling validate, validate_pos or validate_with. The code is just the bare bones of Params::Validate's API, with the same function calls and prototypes. Show quoted text
> Params::Validate::Dummy ':all';
From the synopsis: use Params::Validate::Dummy qw(); use Module::Optional qw(Params::Validate); Show quoted text
> > sub mysub { > my ($scalar, $hashref) = validate_pos( > @_, > {type => SCALAR}, > {type => HASHREF} > );
This will just pass through @_ assigning $_[1] to $hashref Show quoted text
> %$hashref = validate_with( > params => $hashref, > spec => { > key => { > type => SCALAR, > }, > key_optional => { > type => SCALAR, > optional => 1, > default => 'default value for optialal key', > }, > }, > called => '2nd Parameter hashref', > );
This will just pass through the 'params' value passed in Show quoted text
> > return $hashref->{key_optional}; > } > > # return value is now undef and not 'default value for optialal key' > like Params::Validate.
This is expected as you are looking at the original hashref completely intact.
As this is just a documentation change, I won't upload to CPAN until I need to make a code change. The changed files are available from svn. Please read the documentation and let me know if the usage still is not clear. http://www.ivorw.com/svn/cpan/Module-Optional/trunk/