Validation::Class::Errors(3pm)

Validation::Class::Errors3pm

Error handling object for fields and classes

Usage

    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;

Version

version 7.70

Overview

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

Methods

new

    my $self = Validation::Class::Errors->new;

add

    $self = $self->add("houston, we have a problem", "this isn't cool");

all

    my @list = $self->all;

clear

    $self = $self->clear;

count

    my $count = $self->count;

each

    my $list = $self->each(sub{ ucfirst lc shift });

list

    my $list = $self->list;

find

    my @matches = $self->find(qr/password/);

first

    my $item = $self->first;
    my $item = $self->first(qr/password/);

join

    my $string = $self->join; # returns "an error, another error"
    
    my $string = $self->join($delimiter);

to_string

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 });

Author

Al Newkirk <[email protected]>

From libvalidation-class-perl 7.70-1 in Debian 7 (Wheezy). Parsed by carta from the page's man source.