Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Dancer param rewrite

by Skeeve (Vicar)
on Jan 23, 2014 at 15:31 UTC ( #1071770=perlquestion: print w/replies, xml ) Need Help??
Skeeve has asked for the wisdom of the Perl Monks concerning the following question:

Sorry for the title... I couldn't think of a better one.

I'm writing a Dancer application and was wondering whether or not there is a way to change the data the user supplied.

I have, for example, a date input field where the user is expected to enter data in ISO format. But I could be "forgiving" and accept something like "2014-1-3" and rewrite it to "2014-01-03".

But I couldn't find a way yet to assign a value to my param('dateinput'). Is there a way at all?


Replies are listed 'Best First'.
Re: Dancer param rewrite
by kschwab (Priest) on Jan 23, 2014 at 16:34 UTC
    There's Dancer::Plugin::Params::Normization. Perhaps a bit heavy (you'll have to write a custom class), but the overview indicates this functionality is there for the exact reason you've posted.

      Sorry, but no. I read the description as normalization of the parameter names. So whether someone supplied "NAME=John" or "name=John" to the path, the result will be that the parameter name becomes "name" when "lowercase is set as normalization.

        Yes, that is the example, but read a bit further on the part about the custom class...
        normalize($hashref) Receives a hashref that contains the parameters keys/value. It should +return a hashref (it can be the same), containing modified parameters +.
        Sounds like you can modify values as well, since you're returning a hashref with both keys and values.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1071770]
Front-paged by Corion
and the voices are still...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2018-05-24 12:51 GMT
Find Nodes?
    Voting Booth?