Data::Verifier::Filters - Filters for values
$dv->verify({ name => { type => 'Str' filters => [ qw(collapse trim) ] } }); $dv->get_value('name');
Adding a custom filter may be done by providing a coderef as one of the filters:
# Remove all whitespace my $sub = sub { my ($val) = @_; $val =~ s/\s//g; $val } $dv->verify({ name => { type => 'Str' filters => [ $sub ] } }); $dv->get_value('name'); # No whitespace!
These filters are supplied free of charge. Since they are common, it made sense to include them. Patches are welcome for other filters that might be used commonly.
Collapses all consecutive whitespace into a single space
Removes all whitespace.
Converts the value to lowercase.
Removes leading and trailing whitespace
Converts the value to uppercase.
Cory G Watson, <gphat at cpan.org>
<gphat at cpan.org>
Copyright 2009 Cold Hard Code, LLC
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Data::Verifier, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Verifier
CPAN shell
perl -MCPAN -e shell install Data::Verifier
For more information on module installation, please visit the detailed CPAN module installation guide.