Hello russianspy-ga,
Thank-you for your question.
Data::FormValidator has a filter that can allow you to trim the
leading/trailing characters.
"filters
# trim leading and trailing whitespace on all fields
filters => ['trim'],
This is a reference to an array of filters that will be applied to ALL
optional and required fields.
This can be the name of a built-in filter (trim,digit,etc) or an
anonymous subroutine which should take one parameter, the field value
and return the (possibly) modified value.
Filters modify the data, so use them carefully.
See Data::FormValidator::Filters for details on the built-in filters."
http://search.cpan.org/~markstos/Data-FormValidator-4.00_02/lib/Data/FormValidator.pm#filters
The detail page for Data::FormValidator::Filters can be found here:
http://search.cpan.org/~markstos/Data-FormValidator-4.14/lib/Data/FormValidator/Filters.pm
I don't have my system set-up to fully verify this but it should make
your subroutine something like this:
sub validate_form {
my $q = shift;
my $profile = {
'required' => [qw(email)],
'constraints'=> {
'email' => 'email'
},
'filters' => [ 'trim' ]
};
my $results = Data::FormValidator->check($q,$profile);
return $results;
}
If you need any further assistance please post as much information as
possible (including any webpages and code you have already) and ask
for clarification. I will do my best to respond swiftly. |