Apache-iNcom
view release on metacpan or search on metacpan
lib/HTML/FormValidator.pm view on Meta::CPAN
quotemeta $_[0];
}
=pod
=item lc
Calls the lc (convert to lowercase) builtin on its input.
=cut
sub filter_lc {
lc $_[0];
}
=pod
=item uc
Calls the uc (convert to uppercase) builtin on its input.
=cut
sub filter_uc {
uc $_[0];
}
=pod
=item ucfirst
Calls the ucfirst (Uppercase first letter) builtin on its input.
=cut
sub filter_ucfirst {
ucfirst $_[0];
}
=pod
=back
=head1 BUILTIN VALIDATOR
Those are the builtin constraint that can be specified by name in the
input profiles.
=over
=item email
Checks if the email LOOKS LIKE an email address. This checks if the
input contains one @, and a two level domain name. The address portion
is checked quite liberally. For example, all those probably invalid
address would pass the test :
nobody@top.domain
%?&/$()@nowhere.net
guessme@guess.m
=cut
# Many of the following validator are taken from
# MiniVend 3.14. (http://www.minivend.com)
# Copyright 1996-1999 by Michael J. Heins <mike@heins.net>
sub valid_email {
my $email = shift;
return $email =~ /[\040-\176]+\@[-A-Za-z0-9.]+\.[A-Za-z]+/;
}
my $state = <<EOF;
AL AK AZ AR CA CO CT DE FL GA HI ID IL IN IA KS KY LA ME MD
MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA PR RI
SC SD TN TX UT VT VA WA WV WI WY DC AP FP FPO APO GU VI
EOF
my $province = <<EOF;
AB BC MB NB NF NS NT ON PE QC SK YT YK
EOF
=pod
=item state_or_province
This one checks if the input correspond to an american state or a canadian
province.
=cut
sub valid_state_or_province {
return valid_state(@_) || valid_province(@_);
}
=pod
=item state
This one checks if the input is a valid two letter abbreviation of an
american state.
=cut
sub valid_state {
my $val = shift;
return $state =~ /\b$val\b/i;
}
=pod
=item province
This checks if the input is a two letter canadian province
abbreviation.
=cut
sub valid_province {
( run in 0.663 second using v1.01-cache-2.11-cpan-39bf76dae61 )