line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::SchemaValidator::Result; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
82795
|
use strict; |
|
4
|
|
|
|
|
20
|
|
|
4
|
|
|
|
|
120
|
|
4
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
118
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
669
|
use JSON; |
|
4
|
|
|
|
|
10156
|
|
|
4
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
9
|
|
|
9
|
0
|
9300
|
my $class = shift; |
10
|
9
|
|
|
|
|
23
|
my (%params) = @_; |
11
|
|
|
|
|
|
|
|
12
|
9
|
|
|
|
|
17
|
my $self = {}; |
13
|
9
|
|
|
|
|
19
|
bless $self, $class; |
14
|
|
|
|
|
|
|
|
15
|
9
|
|
|
|
|
24
|
$self->{errors} = []; |
16
|
9
|
|
100
|
|
|
38
|
$self->{root} = $params{root} || '#'; |
17
|
|
|
|
|
|
|
|
18
|
9
|
|
|
|
|
34
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub is_success { |
22
|
6
|
|
|
6
|
0
|
17
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
6
|
|
|
|
|
10
|
return @{$self->{errors}} == 0; |
|
6
|
|
|
|
|
28
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub errors { |
28
|
6
|
|
|
6
|
0
|
26
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
|
|
43
|
return $self->{errors}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub errors_json { |
34
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
return JSON::encode_json($self->{errors}); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub add_error { |
40
|
6
|
|
|
6
|
0
|
34
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
6
|
100
|
|
|
|
19
|
if (@_ == 1) { |
43
|
1
|
|
|
|
|
3
|
my ($error) = @_; |
44
|
1
|
|
|
|
|
4
|
foreach my $suberror (@{$error->errors}) { |
|
1
|
|
|
|
|
3
|
|
45
|
1
|
|
|
|
|
2
|
push @{$self->{errors}}, $suberror; |
|
1
|
|
|
|
|
4
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
5
|
|
|
|
|
21
|
my %params = @_; |
50
|
|
|
|
|
|
|
|
51
|
5
|
|
|
|
|
12
|
my $uri = $params{uri}; |
52
|
5
|
100
|
66
|
|
|
41
|
if ($self->{root} && $self->{root} ne '#') { |
53
|
1
|
|
|
|
|
8
|
$uri =~ s{^#}{$self->{root}}; |
54
|
1
|
|
|
|
|
6
|
$params{uri} = $uri; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
5
|
|
|
|
|
9
|
push @{$self->{errors}}, {%params}; |
|
5
|
|
|
|
|
28
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
6
|
|
|
|
|
31
|
return $self; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub merge { |
64
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
65
|
3
|
|
|
|
|
6
|
my ($subresult) = @_; |
66
|
|
|
|
|
|
|
|
67
|
3
|
100
|
|
|
|
6
|
return $self if $subresult->is_success; |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
5
|
foreach my $suberror (@{$subresult->errors}) { |
|
2
|
|
|
|
|
7
|
|
70
|
2
|
|
|
|
|
4
|
push @{$self->{errors}}, $suberror; |
|
2
|
|
|
|
|
6
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
7
|
return $self; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |