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   4 use namespace::autoclean;
  1         2  
  1         6  
4              
5 1     1   55 use Unexpected::Functions qw( has_exception );
  1         1  
  1         10  
6 1     1   327 use Moo;
  1         2  
  1         7  
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__
79              
80             =pod
81              
82             =encoding utf-8
83              
84             =head1 Name
85              
86             Data::Validation::Exception - Defines the exceptions throw by the distribution
87              
88             =head1 Synopsis
89              
90             use Data::Validation::Exception;
91              
92             =head1 Description
93              
94             Defines the exceptions throw by the distribution
95              
96             =head1 Configuration and Environment
97              
98             Defines the following exceptions;
99              
100             =over 3
101              
102             =item C<InvalidParameter>
103              
104             =item C<BetweenValues>
105              
106             =item C<EqualTo>
107              
108             =item C<FieldComparison>
109              
110             =item C<Hexadecimal>
111              
112             =item C<KnownType>
113              
114             =item C<Mandatory>
115              
116             =item C<MatchingRegex>
117              
118             =item C<MatchingType>
119              
120             =item C<Printable>
121              
122             =item C<SimpleText>
123              
124             =item C<ValidHostname>
125              
126             =item C<ValidIdentifier>
127              
128             =item C<ValidInteger>
129              
130             =item C<ValidLength>
131              
132             =item C<ValidNumber>
133              
134             =item C<ValidationErrors>
135              
136             =back
137              
138             =head1 Subroutines/Methods
139              
140             None
141              
142             =head1 Diagnostics
143              
144             None
145              
146             =head1 Dependencies
147              
148             =over 3
149              
150             =item L<Unexpected>
151              
152             =back
153              
154             =head1 Incompatibilities
155              
156             There are no known incompatibilities in this module
157              
158             =head1 Bugs and Limitations
159              
160             There are no known bugs in this module. Please report problems to
161             http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-Validation.
162             Patches are welcome
163              
164             =head1 Acknowledgements
165              
166             Larry Wall - For the Perl programming language
167              
168             =head1 Author
169              
170             Peter Flanigan, C<< <pjfl@cpan.org> >>
171              
172             =head1 License and Copyright
173              
174             Copyright (c) 2016 Peter Flanigan. All rights reserved
175              
176             This program is free software; you can redistribute it and/or modify it
177             under the same terms as Perl itself. See L<perlartistic>
178              
179             This program is distributed in the hope that it will be useful,
180             but WITHOUT WARRANTY; without even the implied warranty of
181             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
182              
183             =cut
184              
185             # Local Variables:
186             # mode: perl
187             # tab-width: 3
188             # End:
189             # vim: expandtab shiftwidth=3: