Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: A Refactoring We Will Go

by hacker (Priest)
on Jul 01, 2003 at 15:05 UTC ( [id://270498]=note: print w/replies, xml ) Need Help??


in reply to A Refactoring We Will Go

Params::Check looks like it is the right module for use here, and I managed to get it working, somewhat (with a slight syntax poke/help from jeffa). Now the problem is that I need to generate a custom error message when the params are incorrect (instead of the generic die "Could not parse arguments\n"; message).

For example, if I accept a date range in 'blort' above ($conf{'template'}->{'blort'}) of the format YYYY-MM-DD, and the value supplied by the template's value in that key is DD-MM-YYYY, I would like to die with an error specific to that key, and then return a list of the proper syntax, such as:

"Date format incorrect, please supply the date in the format YYYY-MM-DD for proper parsing."

How would I go about doing that? I see that in Params::Check, I can run another sub inside the accept() object to pass the args, and validate that way, but now I'm back to doing ~40 different calls to that check, which is back to where I started.

Replies are listed 'Best First'.
Re^2: A Refactoring We Will Go (patch)
by tye (Sage) on Jul 01, 2003 at 15:36 UTC

    I'd patch the module to support a custom message per parameter.

                    - tye

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-23 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found