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