
Validation::Class::Errors - Error Handling Object for Fields and Classes

version 7.16

package SomeClass;
use Validation::Class;
package main;
my $class = SomeClass->new;
...
# errors at the class-level
my $errors = $class->errors ;
print $errors->to_string;
# errors at the field-level
my $field_errors = $user->fields->{name}->{errors} ;
print $field_errors->to_string;
1;

Validation::Class::Errors is responsible for error handling in Validation::Class derived classes on both the class and field levels respectively.

my $self = Validation::Class::Errors->new;
$self = $self->add("houston, we have a problem", "this isn't cool");
my @list = $self->all;
$self = $self->clear;
my $count = $self->count;
my $list = $self->each(sub{ ucfirst lc shift });
my $list = $self->list;
my @matches = $self->find(qr/password/);
my $item = $self->first;
my $item = $self->first(qr/password/);
my $string = $self->join; # returns "an error, another error"
my $string = $self->join($delimiter);
The to_string method stringifies the errors using the specified delimiter or ", " (comma-space) by default.
my $string = $self->to_string; # returns "an error, another error"
my $string = $self->to_string($delimiter, sub { ucfirst lc shift });

Al Newkirk <anewkirk@ana.io>

This software is copyright (c) 2011 by Al Newkirk.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.