Form::Tiny::Error - form error wrapper
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');
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.
$error->error
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
To install Form::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Form::Tiny
CPAN shell
perl -MCPAN -e shell install Form::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.