CleanCode Perl Libraries |
Home | Perl | Java | PowerShell | C# | SQL | Index | Tools | Download | What's New |
Multi-Lingual Library | Maintainability | ||||||||||||
Perl | Java | JavaScript | Certified Class |
Testable Class |
Standalone Mode |
Diagnostic Enabled |
CGI::PageValidator - Top-level object for validating data.
use CGI::PageValidator;
$validator = CGI::PageValidator->new($inputData,$libMgr,$namesOnly);
$validator->process();
if (!$validator->success()) {
$errListRef = $validator->errors();
print @$errListRef;
}
Perl5.005, Data::Diagnostic, CGI::PageValidator::CheckItem
This is the main object to process a web form or other input data for validation. As shown in the synopsis, create an object with appropriate parameters, invoke the process
method to do the validation, then handle the resultant list of validation errors (if any).
See the top-level validate.pl
program for a working example on how to set up validation, use this class, and process the results.
PACKAGE->new(inputData, libMgr, namesOnly)
Creates a PageValidator
object that may be used to validate a series of input data items against a library of constraints. The output is a list of violations each of which may be either a string describing the violation, or just the field name (based on the namesOnly
parameter).
inputData
- an InputOptions object; the getDataKeySet
and getProperty
methods are needed to retrieve the list of field names and the value of each field, respectively.
libMgr
- a LibraryMgr object; the getItem
method is needed to retrieve a definition from the library (in the form of a CheckItem object).
namesOnly
- optional; boolean; as the list of validation errors is accumulated, this flag indicates to include only the field names, or a complete message describing the violation.
OBJ->process()
This method clears the error list which will be generated during validation, then validates each input item by calling the doValidate
method of each CheckItem object in the libMgr
provided through the constructor. The generated error list is actually accumulated in the CheckItem
class, so after all items are processed, the error list is retrieved from the library and made available via the errors
method.
OBJ->success()
Indicates whether the primary method of this object ran without error.
Boolean indicating whether process
method executed successfully.
OBJ->errors()
If success
reports failure, this method returns the list of errors for display or other processing.
Reference to array of error message strings; each is either a field name or a descriptive message describing each violation, depending on the namesOnly
flag passed in to the constructor.
None
Michael Sorens
$Revision: 8 $ $Date: 2006-12-19 21:13:43 -0800 (Tue, 19 Dec 2006) $
CleanCode 0.9
bin::validate, CGI::PageValidator::LibraryMgr, CGI::PageValidator::CheckItem, CGI::PageValidator::Plugin, CGI::PageValidator::MainLib::SysLib, CGI::PageValidator::MainLib::UserLib
Hey! The above document had some coding errors, which are explained below:
=back doesn't take any parameters, but you said =back -- end of CONSTRUCTOR section
=back doesn't take any parameters, but you said =back -- end of METHODS section
Home | Perl | Java | PowerShell | C# | SQL | Index | Tools | Download | What's New |
CleanCode Perl Libraries | Copyright © 2001-2013 Michael Sorens - Revised 2013.06.30 |