Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Dependencies, or, How Common is Regexp::Common?

by legLess (Hermit)
on Sep 17, 2003 at 07:02 UTC ( [id://292069]=note: print w/replies, xml ) Need Help??


in reply to Re: Dependencies, or, How Common is Regexp::Common?
in thread Dependencies, or, How Common is Regexp::Common?

The error is in your assumption of how the code is used. The routine I gave doesn't do any validation at all, it just returns a quoted regex which is used elsewhere in the code to properly untaint incoming data:

# $value set to incoming parameter earlier # $param object initialized earlier my $valex = $param->valex; $value =~ /($valex)/; $param->errors( "Parameter '" . $param->name . "' contained invalid data." ) unless(( defined $1 ) and ( $value eq $1 )); $param->value( $1 );

Just for the heck of it I added another test, passing a parameter called 'bart' with a value of 'foo123abc'. I defined 'bart' as an integer and watched this test pass:

is( $valop->value( 'bart' ), 123, 'foo123abc validated correctly' );

Thanks for the reply, though.

UPDATE: I should note that one of the simplifications I made (not expecting the Spanish Inquisition, as they say) to the code in my original post was changing this line in the module:

$_ = shift || $self->validator;

to:

$_ = shift;

In the module, &valex serves a dual purpose which I didn't think pertinent to the question I was asking.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://292069]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2024-04-23 19:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found