CGI::ArgChecker - An extensible CGI parameter validation module (allowing commonly used checks on parameters to be called more concisely and consistently). use CGI::ArgChecker; $checker = new CGI::Argchecker; $checker->register_check($name, \&sub); $checker->error_handler(\&errhandler); $checker->argcheck($CGI_query_object, 'param_name' => [ 'expectation', ... ], ... ); Note: Since this is really a simple wrapper around String::Checker(3), most of the interesting reading is in that document (i.e. the definition of an 'expectation'). The documentation that follows assumes you are pretty familiar with String::Checker(3), and focuses on the additional functionality provided by this module.

CGI Parameter Checking
The argcheck() method takes a CGI object (can be any of the CGI modules which have a param method for fetching a parameter...) followed by a list of parameter_name/expectation_list_reference pairs. The parameter name is the name of a CGI variable to examine. The expectation list is precisely the same as the String::Checker(3) expectation list. Each parameter will be retrieved from the CGI object using the param() method, checked against all the expectations, and then the result of all checks will be stored for returning. If all parameters pass all expectations, a reference to a hash will be returned, containing parameter_name/parameter_value pairs. If any expectation fails, the hash will still be returned. To check whether any errors occurred, check the 'ERROR' hash value (a boolean flag value). For every expectation which fails, in addition, an error handling routine (described below) will be called.

Error Handling
Using the error_handler() method, you can register a chunk of code which will be called for every expectation which fails. This subroutine will be called with two arguments: the name of the parameter which failed, and the name of the expectation which failed. The return value of the error handling code is ignored. Hopefully none. J. David Lowe, dlowe@webjuice.com perl(1), String::Checker(3)