| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
38
|
|
|
38
|
|
27522
|
use strict; |
|
|
38
|
|
|
|
|
86
|
|
|
|
38
|
|
|
|
|
1595
|
|
|
2
|
38
|
|
|
38
|
|
224
|
use warnings; |
|
|
38
|
|
|
|
|
78
|
|
|
|
38
|
|
|
|
|
3284
|
|
|
3
|
|
|
|
|
|
|
package JSON::Schema::Modern::Vocabulary; |
|
4
|
|
|
|
|
|
|
# vim: set ts=8 sts=2 sw=2 tw=100 et : |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Base role for JSON Schema vocabulary classes |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.634'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
38
|
|
|
38
|
|
695
|
use 5.020; |
|
|
38
|
|
|
|
|
146
|
|
|
10
|
38
|
|
|
38
|
|
223
|
use Moo::Role; |
|
|
38
|
|
|
|
|
114
|
|
|
|
38
|
|
|
|
|
330
|
|
|
11
|
38
|
|
|
38
|
|
21716
|
use strictures 2; |
|
|
38
|
|
|
|
|
361
|
|
|
|
38
|
|
|
|
|
1672
|
|
|
12
|
38
|
|
|
38
|
|
18593
|
use stable 0.031 'postderef'; |
|
|
38
|
|
|
|
|
752
|
|
|
|
38
|
|
|
|
|
314
|
|
|
13
|
38
|
|
|
38
|
|
8000
|
use experimental 'signatures'; |
|
|
38
|
|
|
|
|
87
|
|
|
|
38
|
|
|
|
|
172
|
|
|
14
|
38
|
|
|
38
|
|
2604
|
no autovivification warn => qw(fetch store exists delete); |
|
|
38
|
|
|
|
|
76
|
|
|
|
38
|
|
|
|
|
320
|
|
|
15
|
38
|
|
|
38
|
|
3297
|
use if "$]" >= 5.022, experimental => 're_strict'; |
|
|
38
|
|
|
|
|
79
|
|
|
|
38
|
|
|
|
|
958
|
|
|
16
|
38
|
|
|
38
|
|
3563
|
no if "$]" >= 5.031009, feature => 'indirect'; |
|
|
38
|
|
|
|
|
83
|
|
|
|
38
|
|
|
|
|
2960
|
|
|
17
|
38
|
|
|
38
|
|
224
|
no if "$]" >= 5.033001, feature => 'multidimensional'; |
|
|
38
|
|
|
|
|
80
|
|
|
|
38
|
|
|
|
|
2462
|
|
|
18
|
38
|
|
|
38
|
|
258
|
no if "$]" >= 5.033006, feature => 'bareword_filehandles'; |
|
|
38
|
|
|
|
|
96
|
|
|
|
38
|
|
|
|
|
2540
|
|
|
19
|
38
|
|
|
38
|
|
244
|
no if "$]" >= 5.041009, feature => 'smartmatch'; |
|
|
38
|
|
|
|
|
92
|
|
|
|
38
|
|
|
|
|
1819
|
|
|
20
|
38
|
|
|
38
|
|
212
|
no feature 'switch'; |
|
|
38
|
|
|
|
|
87
|
|
|
|
38
|
|
|
|
|
1574
|
|
|
21
|
38
|
|
|
38
|
|
200
|
use JSON::Schema::Modern::Utilities qw(jsonp assert_keyword_type abort); |
|
|
38
|
|
|
|
|
83
|
|
|
|
38
|
|
|
|
|
3286
|
|
|
22
|
38
|
|
|
38
|
|
263
|
use Carp (); |
|
|
38
|
|
|
|
|
79
|
|
|
|
38
|
|
|
|
|
1045
|
|
|
23
|
38
|
|
|
38
|
|
204
|
use namespace::clean; |
|
|
38
|
|
|
|
|
88
|
|
|
|
38
|
|
|
|
|
335
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @CARP_NOT = qw(JSON::Schema::Modern); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
requires qw(vocabulary keywords); |
|
28
|
|
|
|
|
|
|
|
|
29
|
3
|
|
|
3
|
1
|
14
|
sub evaluation_order { 999 } # override, if needed |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
0
|
0
|
sub BUILD { die 'these classes are never instantiated' } |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
1
|
0
|
sub traverse ($class, $schema, $state) { |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
34
|
0
|
|
|
|
|
0
|
$state->{evaluator}->_traverse_subschema($schema, $state); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
6794
|
|
|
6794
|
1
|
14537
|
sub traverse_subschema ($class, $schema, $state) { |
|
|
6794
|
|
|
|
|
13711
|
|
|
|
6794
|
|
|
|
|
12092
|
|
|
|
6794
|
|
|
|
|
11601
|
|
|
|
6794
|
|
|
|
|
13832
|
|
|
38
|
|
|
|
|
|
|
$state->{evaluator}->_traverse_subschema($schema->{$state->{keyword}}, |
|
39
|
6794
|
|
|
|
|
135111
|
+{ %$state, keyword_path => $state->{keyword_path}.'/'.$state->{keyword} }); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
3821
|
|
|
3821
|
1
|
8784
|
sub traverse_array_schemas ($class, $schema, $state) { |
|
|
3821
|
|
|
|
|
8505
|
|
|
|
3821
|
|
|
|
|
7587
|
|
|
|
3821
|
|
|
|
|
7244
|
|
|
|
3821
|
|
|
|
|
7062
|
|
|
43
|
3821
|
50
|
|
|
|
18026
|
return if not assert_keyword_type($state, $schema, 'array'); |
|
44
|
3821
|
50
|
|
|
|
20420
|
return E($state, '%s array is empty', $state->{keyword}) if not $schema->{$state->{keyword}}->@*; |
|
45
|
|
|
|
|
|
|
|
|
46
|
3821
|
|
|
|
|
8920
|
my $valid = 1; |
|
47
|
3821
|
|
|
|
|
22067
|
foreach my $idx (0 .. $schema->{$state->{keyword}}->$#*) { |
|
48
|
|
|
|
|
|
|
$valid = 0 if not $state->{evaluator}->_traverse_subschema($schema->{$state->{keyword}}[$idx], |
|
49
|
6840
|
100
|
|
|
|
137657
|
+{ %$state, keyword_path => $state->{keyword_path}.'/'.$state->{keyword}.'/'.$idx }); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
3821
|
|
|
|
|
21032
|
return $valid; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
6983
|
|
|
6983
|
1
|
14190
|
sub traverse_object_schemas ($class, $schema, $state) { |
|
|
6983
|
|
|
|
|
16652
|
|
|
|
6983
|
|
|
|
|
12629
|
|
|
|
6983
|
|
|
|
|
13631
|
|
|
|
6983
|
|
|
|
|
12612
|
|
|
55
|
6983
|
100
|
|
|
|
29440
|
return if not assert_keyword_type($state, $schema, 'object'); |
|
56
|
|
|
|
|
|
|
|
|
57
|
6980
|
|
|
|
|
14837
|
my $valid = 1; |
|
58
|
6980
|
|
|
|
|
47135
|
foreach my $property (sort keys $schema->{$state->{keyword}}->%*) { |
|
59
|
|
|
|
|
|
|
$valid = 0 if not $state->{evaluator}->_traverse_subschema($schema->{$state->{keyword}}{$property}, |
|
60
|
10311
|
100
|
|
|
|
106348
|
+{ %$state, keyword_path => jsonp($state->{keyword_path}, $state->{keyword}, $property) }); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
6980
|
|
|
|
|
32438
|
return $valid; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
280
|
|
|
280
|
1
|
618
|
sub traverse_property_schema ($class, $schema, $state, $property) { |
|
|
280
|
|
|
|
|
649
|
|
|
|
280
|
|
|
|
|
583
|
|
|
|
280
|
|
|
|
|
638
|
|
|
|
280
|
|
|
|
|
594
|
|
|
|
280
|
|
|
|
|
510
|
|
|
66
|
280
|
50
|
|
|
|
988
|
return if not assert_keyword_type($state, $schema, 'object'); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$state->{evaluator}->_traverse_subschema($schema->{$state->{keyword}}{$property}, |
|
69
|
280
|
|
|
|
|
3347
|
+{ %$state, keyword_path => jsonp($state->{keyword_path}, $state->{keyword}, $property) }); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
13685
|
|
|
13685
|
1
|
32740
|
sub eval ($class, $data, $schema, $state) { |
|
|
13685
|
|
|
|
|
26118
|
|
|
|
13685
|
|
|
|
|
27790
|
|
|
|
13685
|
|
|
|
|
22999
|
|
|
|
13685
|
|
|
|
|
23460
|
|
|
|
13685
|
|
|
|
|
21351
|
|
|
73
|
13685
|
|
|
|
|
78899
|
$state->{evaluator}->_eval_subschema($data, $schema, $state); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
3960
|
|
|
3960
|
1
|
10551
|
sub eval_subschema_at_uri ($class, $data, $schema, $state, $uri) { |
|
|
3960
|
|
|
|
|
9807
|
|
|
|
3960
|
|
|
|
|
8913
|
|
|
|
3960
|
|
|
|
|
9191
|
|
|
|
3960
|
|
|
|
|
7879
|
|
|
|
3960
|
|
|
|
|
7498
|
|
|
|
3960
|
|
|
|
|
7222
|
|
|
77
|
3960
|
|
|
|
|
27015
|
my $schema_info = $state->{evaluator}->_fetch_from_uri($uri); |
|
78
|
3960
|
100
|
|
|
|
32479
|
abort($state, 'EXCEPTION: unable to find resource "%s"', $uri) if not $schema_info; |
|
79
|
|
|
|
|
|
|
abort($state, 'EXCEPTION: bad reference to "%s": not a schema', $schema_info->{canonical_uri}) |
|
80
|
3954
|
100
|
|
|
|
25467
|
if $schema_info->{document}->get_entity_at_location($schema_info->{document_path}) ne 'schema'; |
|
81
|
|
|
|
|
|
|
|
|
82
|
3951
|
|
|
|
|
20668
|
my $scope_uri = $schema_info->{canonical_uri}->clone->fragment(undef); |
|
83
|
3951
|
100
|
|
|
|
421060
|
push $state->{dynamic_scope}->@*, $scope_uri if $state->{dynamic_scope}->[-1] ne $scope_uri; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
return $state->{evaluator}->_eval_subschema($data, $schema_info->{schema}, |
|
86
|
|
|
|
|
|
|
+{ |
|
87
|
|
|
|
|
|
|
%$state, |
|
88
|
|
|
|
|
|
|
# keyword is assumed to be json pointer-encoded (if a suffix path is needed), so we just concat |
|
89
|
|
|
|
|
|
|
traversed_keyword_path => $state->{traversed_keyword_path}.$state->{keyword_path}.'/'.$state->{keyword}, |
|
90
|
|
|
|
|
|
|
initial_schema_uri => $schema_info->{canonical_uri}, |
|
91
|
3951
|
|
|
|
|
1593761
|
$schema_info->%{qw(document specification_version vocabularies)}, |
|
92
|
|
|
|
|
|
|
keyword_path => '', |
|
93
|
|
|
|
|
|
|
}); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |