The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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.