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::Required

  • Form::Tiny::Error::IsntStrict

  • Form::Tiny::Error::DoesNotValidate