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.
|
|---|