Apache-iNcom
view release on metacpan or search on metacpan
* lib/Apache/iNcom.pm:
(offset_calc) Method grabbed from CGI.pm.
(request_handler) Call cleanup_aliases.
(error_handler) Call cleanup_aliases.
(request_cleanup) Delete expired sessions.
2000-03-17 Francis J. Lacoste <francis.lacoste@iNsu.COM>
* lib/HTML/FormValidator.pm:
(validate) Fixed field_filters processing.
(filters) Added integer, pos_integer, neg_integer,
decimal, pos_decimal, neg_decimal,
dollars and phone filters.
(filter_trim) Fixed return value.
(valid_american_phone) True if more than 7 digits.
(valid_phone) True if more than 6 digits.
2000-02-25 Francis J. Lacoste <francis.lacoste@iNsu.COM>
(DESTROY): Disconnect from the database if we opened the connection
in the constructor.
(sql_do): Query isn't checked for INSERT|UPDATE|DELETE.
(record_search,template_search): Renamed incom_* parameters to
dbix_sp_*.
(pod): Started module documentation.
* lib/HTML/FormValidator.pm (new): The input profiles
specification can be passed directly to the constructor instead of
a file name.
(validate): If the constraints string looks like a regexp compile an
anonymous subroutines which match that regexp.
(postcode): Allow space or dash inside the postal code.
(filter_trim,filter_strip): Moved white space stripping code in
its own filter.
(pod): Added module documentation.
* lib/Apache/Session/DBIUUStore.pm (new): Renamed parameters to
DataSource, UserName, Password for DBIStore compatibility.
(DESTROY): If the database handle was opened by the module,
disconnect the connection on DESTROY to prevent spurious warnings.
lib/HTML/FormValidator.pm view on Meta::CPAN
#
# FormValidator.pm - Object that validates form input data.
#
# This file is part of FormValidator.
#
# Author: Francis J. Lacoste <francis.lacoste@iNsu.COM>
#
# Copyright (C) 1999 Francis J. Lacoste, iNsu Innovations
# Parts Copyright 1996-1999 by Michael J. Heins <mike@heins.net>
# Parts Copyright 1996-1999 by Bruce Albrecht <bruce.albrecht@seag.fingerhut.com>
#
# Parts of this module are based on work by
lib/HTML/FormValidator.pm view on Meta::CPAN
HTML::FormValidator - Validates user input (usually from an HTML form) based
on input profile.
=head1 SYNOPSIS
In an HTML::Empberl page:
use HTML::FormValidator;
my $validator = new HTML::FormValidator( "/home/user/input_profiles.pl" );
my ( $valid, $missing, $invalid, $unknown ) = $validator->validate( \%fdat, "customer_infos" );
=head1 DESCRIPTION
HTML::FormValidator's main aim is to make the tedious coding of input
validation expressible in a simple format and to let the programmer focus
on more interesting task.
When you are coding web application one of the most tedious though
crucial task is to validate user's input (usually submitted by way of
an HTML form). You have to check that each required fields is present
and that some feed have valid data. (Does the phone input looks like a
phone number ? Is that a plausible email address ? Is the YY state
valid ? etc.) For simple form, this is not really a problem but as
forms get more complex and you code more of them this task became
really boring and tedious.
HTML::FormValidator lets you defines profiles which defines the
required fields and their format. When you are ready to validate the
user's input, you tell HTML::FormValidator the profile to apply to the
user data and you get the valid fields, the name of the fields which
are missing, the name of the fields that contains invalid input and
the name of the fields that are unknown to this profile.
You are then free to use this information to build a nice display to
the user telling which fields that he forgot to fill.
=cut
lib/HTML/FormValidator.pm view on Meta::CPAN
array of filters like for the filters parameter.
=item constraints
This is a reference to an hash which contains the constraints that
will be used to check wheter or not the field contains valid data.
Constraint can be either the name of a builtin constraint function
(see below), a perl regexp or an anonymous subroutine which will check
the input and return true or false depending on the input's validity.
The constraint function takes one parameter, the input to be validated
and returns true or false. It is possible to specify the parameters
that will be passed to the subroutine. For that use an hash reference
which contains in the I<constraint> element, the anonymous subroutine
or the name of the builtin and in the I<params> element the name of
the fields to pass a parameter to the function. (Don't forget to
include the name of the field to check in that list!) For an example,
look at the I<cc_no> constraint example.
=back
lib/HTML/FormValidator.pm view on Meta::CPAN
unless ref $self->{profiles} eq "HASH";
$self->{profiles_mtime} = $mtime;
}
=pod
=head1 VALIDATING INPUT
my( $valids, $missings, $invalids, $unknowns ) =
$validator->validate( \%fdat, "customer_infos" );
To validate input you use the validate() method. This method takes two
parameters :
=over
=item data
Contains an hash which should correspond to the form input as
submitted by the user. This hash is not modified by the call to validate.
=item profile
Can be either a name which will be used to lookup the corresponding profile
in the input profiles specification, or it can be an hash reference to the
input profile which should be used.
=back
This method returns a 4 elements array.
lib/HTML/FormValidator.pm view on Meta::CPAN
=item unknowns
This is a list of fields which are unknown to the profile. Whether or
not this indicates an error in the user input is application
dependant.
=back
=cut
sub validate {
my ( $self, $data, $name ) = @_;
my $profile;
if ( ref $name ) {
$profile = $name;
} else {
$self->load_profiles;
$profile = $self->{profiles}{$name};
die "No such profile $name\n" unless $profile;
}
( run in 0.264 second using v1.01-cache-2.11-cpan-a5abf4f5562 )