GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Form::Sensible::Validator(3) User Contributed Perl Documentation Form::Sensible::Validator(3)

Form::Sensible::Validator - Default Validator for Form::Sensible forms

    use Form::Sensible::Validator;
    
    my $object = Form::Sensible::Validator->new();

    $validator_result = $object->validate($form);

Form::Sensible::Validator performs the grunt work of validating a form. It understands how to handle regex based field validation as well as coderef based field validation. It also is responsible for calling field-type specific validation. Usually this class is not manipulated directly. Instead, "$form->validate()" is used, which in turn calls the validator already associated with the form (or creates one if none is already defined).

"validate($form)"
Performs validation of a Form. Returns a Form::Sensible::Validator::Result object with the results of form validation for the passed form.
"validate_field($field)"
Performs complete validation on the given field. Returns an array of hashes containing error messaging (or an empty array on success.) Each hash returned will contain a key of either 'error' or 'missing' and a value containing the error message.
"validate_field_with_regex($field, $regex)"
Internal routine to perform regex based validation of a field.
"validate_field_with_coderef($field, $coderef)"
Internal routine to perform code based validation of a field. When called, the $coderef is called with the field's value as the first argument, and the field itself as the second:

    $coderef->($field_value, $field);
    

The subroutine is expected to return 0 on successful validation, or an appropriate error message on failed validation. This may seem somewhat confusing, returning 0 on a valid field. It may help to think of the coderef as being the equivalent of a "is_field_invalid()" routine.

message_delegate: ($caller, $field, $message)
The message_delegate is used to assemble error and other validation related messages. By default the message_delegate simply loads $message and replaces any occurance of "_FIELDNAME_" with the field's name. Should return the processed message. This is an ideal place to handle localization of messages or other customization. If no translation can be found, you are strongly encouraged to return the message as is (with "_FIELDNAME_" converted to the actual field name, of course.)

Jay Kuri - <jayk@cpan.org>

Ionzero LLC. <http://ionzero.com/>

Form::Sensible

Copyright 2009 by Jay Kuri <jayk@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2012-02-02 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.