File Coverage

lib/Data/Validation/Exception.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Data::Validation::Exception;
2              
3 1     1   3 use namespace::autoclean;
  1         2  
  1         4  
4              
5 1     1   46 use Unexpected::Functions qw( has_exception );
  1         1  
  1         9  
6 1     1   302 use Moo;
  1         1  
  1         6  
7              
8             extends q(Unexpected);
9             with q(Unexpected::TraitFor::ExceptionClasses);
10              
11             my $class = __PACKAGE__;
12              
13             has_exception $class;
14              
15             has_exception 'InvalidParameter' => parents => [ $class ];
16              
17             has_exception 'Allowed' => parents => [ 'InvalidParameter' ],
18             error => 'Parameter [_1] is not in the list of allowed values';
19              
20             has_exception 'BetweenValues' => parents => [ 'InvalidParameter' ],
21             error => 'Parameter [_1] is not in range';
22              
23             has_exception 'EqualTo' => parents => [ 'InvalidParameter' ],
24             error => 'Parameter [_1] is not equal to the required value';
25              
26             has_exception 'FieldComparison' => parents => [ 'InvalidParameter' ],
27             error => 'Field [_1] does not [_2] field [_3]';
28              
29             has_exception 'Hexadecimal' => parents => [ 'InvalidParameter' ],
30             error => 'Parameter [_1] is not a hexadecimal number';
31              
32             has_exception 'Mandatory' => parents => [ 'InvalidParameter' ],
33             error => 'Parameter [_1] is mandatory';
34              
35             has_exception 'MatchingRegex' => parents => [ 'InvalidParameter' ],
36             error => 'Parameter [_1] does not match the required regex';
37              
38             has_exception 'MatchingType' => parents => [ 'InvalidParameter' ],
39             error => 'Parameter [_1] does not of the required type [_3]';
40              
41             has_exception 'Printable' => parents => [ 'InvalidParameter' ],
42             error => 'Parameter [_1] value is not a printable character';
43              
44             has_exception 'SimpleText' => parents => [ 'InvalidParameter' ],
45             error => 'Parameter [_1] is not simple text';
46              
47             has_exception 'ValidHostname' => parents => [ 'InvalidParameter' ],
48             error => 'Parameter [_1] is not a hostname';
49              
50             has_exception 'ValidIdentifier' => parents => [ 'InvalidParameter' ],
51             error => 'Parameter [_1] is not a valid identifier';
52              
53             has_exception 'ValidInteger' => parents => [ 'InvalidParameter' ],
54             error => 'Parameter [_1] is not a valid integer';
55              
56             has_exception 'ValidLength' => parents => [ 'InvalidParameter' ],
57             error => 'Parameter [_1] has an invalid length';
58              
59             has_exception 'ValidNumber' => parents => [ 'InvalidParameter' ],
60             error => 'Parameter [_1] is not a valid number';
61              
62             has_exception 'ValidText' => parents => [ 'InvalidParameter' ],
63             error => 'Parameter [_1] is not valid text';
64              
65             has_exception 'ValidTime' => parents => [ 'InvalidParameter' ],
66             error => 'Parameter [_1] is not a valid time';
67              
68             has_exception 'KnownType' => parents => [ $class ],
69             error => 'Type constraint [_1] is unknown';
70              
71             has_exception 'ValidationErrors' => parents => [ $class ],
72             error => 'There is at least one data validation error';
73              
74             has '+class' => default => $class;
75              
76             1;
77              
78             __END__