The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Form::Tiny::Filter - a representation of a filter

SYNOPSIS

        # in your form class

        # the following will be coerced into Form::Tiny::Filter
        form_filter Str, sub { uc pop() };

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 ($form, $value) and performing the filtering. The scalar $value will already be checked against the type. Should return modified $value.

Required.

METHODS

filter

        $filtered = $filter->filter($filtered, $form);

Checks if $filtered matches the type and runs the code reference. $form is a form instance in which the filtering happens, and will be passed before $filtered. The $filtered value is the last parameter to the coderef, so it can be retrieved using pop().

The return value is the scalar value, either changed or unchanged.