Data::CGIForm 0.4 review

Download
by rbytes.net on

Data::CGIForm is a Perl module with form data interface. Data::CGIForm is yet another way to parse and handle CGI form data

License: Perl Artistic License
File size: 12K
Developer: Tim Wilde
0 stars award from rbytes.net

Data::CGIForm is a Perl module with form data interface.

Data::CGIForm is yet another way to parse and handle CGI form data. The main motivation behind this module was a simple specification based validator that could handle multiple values.
You probably don't want to use this module. CGI::Validate is a much more feature complete take on getting this sort of work done. You may then ask why this is on the CPAN, I ask that of myself from time to time....

SYNOPSIS

my %spec = (
username => qr/^([a-z0-9]+)$/,
password => {
regexp => qr/^([a-z0-9+])$/,
filter => [qw(strip_leading_ws, strip_trailing_ws)],
},
email => {
regexp => qr/^([a-z0-9@.]+)$/,
filter => &qualify_domain,
optional => 1,
errors => {
empty => 'You didn't enter an email address.',
invalid => 'Bad [% key %]: "[% value %]"',
},
extra_test => &check_email_addr,
},
email2 => {
equal_to => email,
errors => {
unequal => 'Both email addresses must be the same.',
},
},
);

my $r = $ENV{'MOD_PERL'} ? Apache::Request->instance : CGI->new;

my $form = Data::CGIForm->new(datasource => $r, spec => %spec);


my @params = $form->params;
foreach $param (@params) {
next unless my $error_string = $form->error($param);

print STDERR $error_string;
}

if ($form->error('username')) {
handle_error($form->username, $form->error('username'));
}

my $email = $form->param('email');
my $password = $form->password;

Requirements:
Perl

Data::CGIForm 0.4 keywords