Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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?


s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Comment on Dancer param rewrite
Select or Download Code
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.


      s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
      +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
        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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1071770]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2014-07-28 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (209 votes), past polls