NAME
Form::Tiny::Filter - a representation of a filter
SYNOPSIS
# in your form class
# the following will be coerced into Form::Tiny::Filter
form_filer Str, sub { uc shift() };
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.
field
A string name of a field that should be filtered, or undef if this filter should execute for every field in the form.
code
A code reference accepting a single scalar and performing the filtering. The scalar will already be checked against the type.
Required.
METHODS
check_field
Accepts a single string, which is a name of a field. Returns a boolean value, which determines whether this filter should be used for that field.
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.