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