File Coverage

blib/lib/Validation/Class/Errors.pm
Criterion Covered Total %
statement 24 24 100.0
branch 4 6 66.6
condition n/a
subroutine 6 6 100.0
pod 1 2 50.0
total 35 38 92.1


line stmt bran cond sub pod time code
1             # Error Handling Object for Fields and Classes
2              
3             # Validation::Class::Errors is responsible for error handling in
4             # Validation::Class derived classes on both the class and field levels
5             # respectively and is derived from the L class.
6              
7             package Validation::Class::Errors;
8              
9 109     109   749 use strict;
  109         231  
  109         3279  
10 109     109   622 use warnings;
  109         251  
  109         3334  
11              
12 109     109   633 use Validation::Class::Util '!has', '!hold';
  109         245  
  109         756  
13              
14             our $VERSION = '7.900059'; # VERSION
15              
16 109     109   756 use base 'Validation::Class::Listing';
  109         249  
  109         28769  
17              
18             sub add {
19              
20 2697     2697 1 4447 my $self = shift;
21              
22 2697 100       5907 my $arguments = isa_arrayref($_[0]) ? $_[0] : [@_];
23              
24 2697         5979 push @{$self}, @{$arguments};
  2697         4510  
  2697         4438  
25              
26 2697         6804 @{$self} = ($self->unique);
  2697         4665  
27              
28 2697         5317 return $self;
29              
30             }
31              
32             sub to_string {
33              
34 36     36 0 124 my ($self, $delimiter, $transformer) = @_;
35              
36 36 50       184 $delimiter = ', ' unless defined $delimiter; # default is a comma-space
37              
38 36 50       146 $self->each($transformer) if $transformer;
39              
40 36         254 return $self->join($delimiter);
41              
42             }
43              
44             1;