| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
38
|
|
|
38
|
|
21264
|
use strict; |
|
|
38
|
|
|
|
|
69
|
|
|
|
38
|
|
|
|
|
1279
|
|
|
2
|
38
|
|
|
38
|
|
135
|
use warnings; |
|
|
38
|
|
|
|
|
61
|
|
|
|
38
|
|
|
|
|
2466
|
|
|
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.641'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
38
|
|
|
38
|
|
548
|
use 5.020; |
|
|
38
|
|
|
|
|
109
|
|
|
10
|
38
|
|
|
38
|
|
135
|
use Moo::Role; |
|
|
38
|
|
|
|
|
60
|
|
|
|
38
|
|
|
|
|
261
|
|
|
11
|
38
|
|
|
38
|
|
15500
|
use strictures 2; |
|
|
38
|
|
|
|
|
253
|
|
|
|
38
|
|
|
|
|
1173
|
|
|
12
|
38
|
|
|
38
|
|
12119
|
use stable 0.031 'postderef'; |
|
|
38
|
|
|
|
|
475
|
|
|
|
38
|
|
|
|
|
190
|
|
|
13
|
38
|
|
|
38
|
|
5370
|
use experimental 'signatures'; |
|
|
38
|
|
|
|
|
91
|
|
|
|
38
|
|
|
|
|
148
|
|
|
14
|
38
|
|
|
38
|
|
1827
|
no autovivification warn => qw(fetch store exists delete); |
|
|
38
|
|
|
|
|
65
|
|
|
|
38
|
|
|
|
|
234
|
|
|
15
|
38
|
|
|
38
|
|
2241
|
use if "$]" >= 5.022, experimental => 're_strict'; |
|
|
38
|
|
|
|
|
62
|
|
|
|
38
|
|
|
|
|
643
|
|
|
16
|
38
|
|
|
38
|
|
2519
|
no if "$]" >= 5.031009, feature => 'indirect'; |
|
|
38
|
|
|
|
|
65
|
|
|
|
38
|
|
|
|
|
2032
|
|
|
17
|
38
|
|
|
38
|
|
162
|
no if "$]" >= 5.033001, feature => 'multidimensional'; |
|
|
38
|
|
|
|
|
60
|
|
|
|
38
|
|
|
|
|
1675
|
|
|
18
|
38
|
|
|
38
|
|
163
|
no if "$]" >= 5.033006, feature => 'bareword_filehandles'; |
|
|
38
|
|
|
|
|
57
|
|
|
|
38
|
|
|
|
|
1606
|
|
|
19
|
38
|
|
|
38
|
|
171
|
no if "$]" >= 5.041009, feature => 'smartmatch'; |
|
|
38
|
|
|
|
|
56
|
|
|
|
38
|
|
|
|
|
1317
|
|
|
20
|
38
|
|
|
38
|
|
189
|
no feature 'switch'; |
|
|
38
|
|
|
|
|
99
|
|
|
|
38
|
|
|
|
|
1090
|
|
|
21
|
38
|
|
|
38
|
|
125
|
use JSON::Schema::Modern::Utilities qw(jsonp assert_keyword_type abort); |
|
|
38
|
|
|
|
|
61
|
|
|
|
38
|
|
|
|
|
2262
|
|
|
22
|
38
|
|
|
38
|
|
174
|
use Carp (); |
|
|
38
|
|
|
|
|
75
|
|
|
|
38
|
|
|
|
|
645
|
|
|
23
|
38
|
|
|
38
|
|
127
|
use namespace::clean; |
|
|
38
|
|
|
|
|
66
|
|
|
|
38
|
|
|
|
|
239
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @CARP_NOT = qw(JSON::Schema::Modern); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
requires qw(vocabulary keywords); |
|
28
|
|
|
|
|
|
|
|
|
29
|
3
|
|
|
3
|
1
|
9
|
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
|
6795
|
|
|
6795
|
1
|
9633
|
sub traverse_subschema ($class, $schema, $state) { |
|
|
6795
|
|
|
|
|
9420
|
|
|
|
6795
|
|
|
|
|
9265
|
|
|
|
6795
|
|
|
|
|
8035
|
|
|
|
6795
|
|
|
|
|
7619
|
|
|
38
|
|
|
|
|
|
|
$state->{evaluator}->_traverse_subschema($schema->{$state->{keyword}}, |
|
39
|
6795
|
|
|
|
|
84999
|
+{ %$state, keyword_path => $state->{keyword_path}.'/'.$state->{keyword} }); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
3821
|
|
|
3821
|
1
|
5744
|
sub traverse_array_schemas ($class, $schema, $state) { |
|
|
3821
|
|
|
|
|
5810
|
|
|
|
3821
|
|
|
|
|
5069
|
|
|
|
3821
|
|
|
|
|
4926
|
|
|
|
3821
|
|
|
|
|
5070
|
|
|
43
|
3821
|
50
|
|
|
|
11326
|
return if not assert_keyword_type($state, $schema, 'array'); |
|
44
|
3821
|
50
|
|
|
|
12604
|
return E($state, '%s array is empty', $state->{keyword}) if not $schema->{$state->{keyword}}->@*; |
|
45
|
|
|
|
|
|
|
|
|
46
|
3821
|
|
|
|
|
5445
|
my $valid = 1; |
|
47
|
3821
|
|
|
|
|
14206
|
foreach my $idx (0 .. $schema->{$state->{keyword}}->$#*) { |
|
48
|
|
|
|
|
|
|
$valid = 0 if not $state->{evaluator}->_traverse_subschema($schema->{$state->{keyword}}[$idx], |
|
49
|
6840
|
100
|
|
|
|
86255
|
+{ %$state, keyword_path => $state->{keyword_path}.'/'.$state->{keyword}.'/'.$idx }); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
3821
|
|
|
|
|
11109
|
return $valid; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
6990
|
|
|
6990
|
1
|
10282
|
sub traverse_object_schemas ($class, $schema, $state) { |
|
|
6990
|
|
|
|
|
9791
|
|
|
|
6990
|
|
|
|
|
9778
|
|
|
|
6990
|
|
|
|
|
9014
|
|
|
|
6990
|
|
|
|
|
8546
|
|
|
55
|
6990
|
100
|
|
|
|
19137
|
return if not assert_keyword_type($state, $schema, 'object'); |
|
56
|
|
|
|
|
|
|
|
|
57
|
6987
|
|
|
|
|
10850
|
my $valid = 1; |
|
58
|
6987
|
|
|
|
|
34130
|
foreach my $property (sort keys $schema->{$state->{keyword}}->%*) { |
|
59
|
|
|
|
|
|
|
$valid = 0 if not $state->{evaluator}->_traverse_subschema($schema->{$state->{keyword}}{$property}, |
|
60
|
10318
|
100
|
|
|
|
69645
|
+{ %$state, keyword_path => jsonp($state->{keyword_path}, $state->{keyword}, $property) }); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
6987
|
|
|
|
|
21592
|
return $valid; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
280
|
|
|
280
|
1
|
439
|
sub traverse_property_schema ($class, $schema, $state, $property) { |
|
|
280
|
|
|
|
|
469
|
|
|
|
280
|
|
|
|
|
410
|
|
|
|
280
|
|
|
|
|
360
|
|
|
|
280
|
|
|
|
|
439
|
|
|
|
280
|
|
|
|
|
355
|
|
|
66
|
280
|
50
|
|
|
|
599
|
return if not assert_keyword_type($state, $schema, 'object'); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$state->{evaluator}->_traverse_subschema($schema->{$state->{keyword}}{$property}, |
|
69
|
280
|
|
|
|
|
2222
|
+{ %$state, keyword_path => jsonp($state->{keyword_path}, $state->{keyword}, $property) }); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
13688
|
|
|
13688
|
1
|
20385
|
sub eval ($class, $data, $schema, $state) { |
|
|
13688
|
|
|
|
|
19127
|
|
|
|
13688
|
|
|
|
|
18441
|
|
|
|
13688
|
|
|
|
|
16118
|
|
|
|
13688
|
|
|
|
|
15542
|
|
|
|
13688
|
|
|
|
|
13990
|
|
|
73
|
13688
|
|
|
|
|
52249
|
$state->{evaluator}->_evaluate_subschema($data, $schema, $state); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
3961
|
|
|
3961
|
1
|
8005
|
sub eval_subschema_at_uri ($class, $data, $schema, $state, $uri) { |
|
|
3961
|
|
|
|
|
6936
|
|
|
|
3961
|
|
|
|
|
6606
|
|
|
|
3961
|
|
|
|
|
6352
|
|
|
|
3961
|
|
|
|
|
5409
|
|
|
|
3961
|
|
|
|
|
5638
|
|
|
|
3961
|
|
|
|
|
5210
|
|
|
77
|
3961
|
|
|
|
|
19323
|
my $schema_info = $state->{evaluator}->_fetch_from_uri($uri); |
|
78
|
3961
|
100
|
|
|
|
20372
|
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
|
3955
|
100
|
|
|
|
16088
|
if $schema_info->{document}->get_entity_at_location($schema_info->{document_path}) ne 'schema'; |
|
81
|
|
|
|
|
|
|
|
|
82
|
3952
|
|
|
|
|
12353
|
my $scope_uri = $schema_info->{canonical_uri}->clone->fragment(undef); |
|
83
|
3952
|
100
|
|
|
|
261762
|
push $state->{dynamic_scope}->@*, $scope_uri if $state->{dynamic_scope}->[-1] ne $scope_uri; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
return $state->{evaluator}->_evaluate_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
|
3952
|
|
|
|
|
974249
|
$schema_info->%{qw(document specification_version vocabularies)}, |
|
92
|
|
|
|
|
|
|
keyword_path => '', |
|
93
|
|
|
|
|
|
|
}); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |