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

NAME

Form::Tiny::Error - form error wrapper

SYNOPSIS

        my $error = Form::Tiny::Error::DoesNotValidate->new(
                field => "some_field",
                error => "some message"
        );

        my $field = $error->field; # field name or undef
        my $data = $error->error; # error message or nested error object

        # concatenated error message: "$field - $data"
        my $message = $error->as_string;

        # change error message
        $error->set_error('new_message');

DESCRIPTION

The form errors class features field name which caused validation error, error message and automatic stringification.

The $error->error can return a nested error object in case of nested forms.

A couple of in-place subclasses are provided to differentiate the type of error which occured. These are:

  • Form::Tiny::Error::InvalidFormat

  • Form::Tiny::Error::DoesNotExist

  • Form::Tiny::Error::IsntStrict

  • Form::Tiny::Error::DoesNotValidate