NAME
Form::Tiny::Filter - a representation of filtering condition
SYNOPSIS
# in your form class
sub build_filters
{
return (
# the following will be coerced into Form::Tiny::Filter
# [ type, filtering sub ]
[Str, sub { ... }],
);
}
DESCRIPTION
This is a simple class which stores a Type::Tiny type and a sub which will perform the filtering.
ATTRIBUTES
type
A Type::Tiny type that will be checked against.
Required.
code
A code reference accepting a single scalar and performing the filtering. The scalar will already be checked against the type.
Required. =head1 METHODS
filter
Accepts a single scalar, checks if it matches the type and runs the code reference with it as an argument.
The return value is the scalar value, either changed or unchanged.