Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
ArgChecker(3)	      User Contributed Perl Documentation	 ArgChecker(3)

       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);
			   '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,

       perl(1),	String::Checker(3)

perl v5.24.1			  1999-11-25			 ArgChecker(3)


Want to link to this manual page? Use this URL:

home | help