line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Validator::Mock; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
106191
|
use Catmandu::Sane; |
|
3
|
|
|
|
|
46
|
|
|
3
|
|
|
|
|
32
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
28
|
use Moo; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
21
|
|
8
|
3
|
|
|
3
|
|
1217
|
use namespace::clean; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
25
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Catmandu::Validator'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has message => (is => 'rw', default => sub {'item is invalid'}); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has reject => (is => 'rw', default => sub {0}); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub validate_data { |
17
|
3
|
|
|
3
|
0
|
8
|
my ($self) = @_; |
18
|
|
|
|
|
|
|
|
19
|
3
|
100
|
|
|
|
14
|
if ($self->reject) { |
20
|
2
|
|
|
|
|
11
|
return [$self->message]; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
__END__ |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=pod |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Catmandu::Validator::Mock - Validate items based on a flag |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use Catmandu::Validator::Mock; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $validator = Catmandu::Validator::Mock->new( |
39
|
|
|
|
|
|
|
message => 'item is invalid', |
40
|
|
|
|
|
|
|
reject => 1, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This L<Catmandu::Validator> can be used for testing as it does not actually |
46
|
|
|
|
|
|
|
look at the data to validate. Instead it rejects items if C<reject> is set to a |
47
|
|
|
|
|
|
|
true value. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 CONFIGURATION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=over |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item message |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Error message to return for rejected items. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item reject |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
The validator marks all items as invalid as long as this flag is true. Default |
60
|
|
|
|
|
|
|
is false. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=back |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SEE ALSO |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
See L<Catmandu::Validator> for inherited methods, common configuration options, |
67
|
|
|
|
|
|
|
and usage. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |