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