line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
613
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
1
|
|
|
1
|
|
6
|
use Catmandu::Util qw(require_package); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
322
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
9
|
1
|
|
|
1
|
|
6
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
10
|
1
|
|
|
1
|
|
271
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
11
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
12
|
|
|
|
|
|
|
has name => (fix_arg => 1); |
13
|
|
|
|
|
|
|
has validator_opts => (fix_opt => 'collect'); |
14
|
|
|
|
|
|
|
has validator => (is => 'lazy', init_arg => undef); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with 'Catmandu::Fix::Condition::Builder::Simple'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
my $validator = $self->validator; |
20
|
2
|
|
|
2
|
|
16
|
sub { |
21
|
2
|
|
|
|
|
27
|
$validator->is_valid($_[0]); |
22
|
|
|
|
|
|
|
} |
23
|
2
|
|
|
2
|
|
7
|
} |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
|
|
13
|
my ($self) = @_; |
26
|
|
|
|
|
|
|
require_package($self->name, 'Catmandu::Validator') |
27
|
|
|
|
|
|
|
->new($self->validator_opts); |
28
|
2
|
|
|
2
|
|
14
|
} |
29
|
2
|
|
|
|
|
8
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=pod |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Catmandu::Fix::Condition::valid - Execute fixes if the data passes validation |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# reject all items not conforming to a schema |
42
|
|
|
|
|
|
|
select valid('', JSONSchema, schema: "my/schema.json") |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# check the author field |
45
|
|
|
|
|
|
|
unless valid(author, JSONSchema, schema: "my/author.schema.json") |
46
|
|
|
|
|
|
|
... # repair or give warning |
47
|
|
|
|
|
|
|
end |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 SEE ALSO |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
See L<Catmandu::Fix::validate> to check and get validation errors. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |