NAME
Chandra::Form::Validator - Form validation for Chandra::Form
SYNOPSIS
use Chandra::Form::Validator;
# Server-side validation (calls XS validate on form)
my $errors = Chandra::Form::Validator->validate($form, \%data);
if ($errors) {
$app->eval($form->show_errors_js($errors));
}
# Client-side validation JS
my $js = Chandra::Form::Validator->validation_js($form);
$app->eval($js);
METHODS
validate($form, \%data)-
Hands the data to the form's own
validateand returns its errors, or undef when there are none. validation_js($form)-
A script that checks the form's fields in the browser with the same rules: required, minlength, maxlength, min, max, a string pattern and an email type. Empty when the form has no rules.