NAME
Data::Verifier::Filters - Filters for values
VERSION
version 0.65
SYNOPSIS
use Data::Verifier;
my $dv = Data::Verifier->new(profile => {
name => {
type => 'Str',
filters => [ qw(collapse trim) ]
}
});
$dv->verify({ name => ' foo bar '});
$dv->get_value('name'); # 'foo bar'
CUSTOM FILTERS
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!
METHODS
collapse
Collapses all consecutive whitespace into a single space
flatten
Removes all whitespace.
lower
Converts the value to lowercase.
trim
Removes leading and trailing whitespace
upper
Converts the value to uppercase.
AUTHOR
Cory G Watson <gphat@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2023 by Cold Hard Code, LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.