line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
20
|
|
|
20
|
|
12898
|
use strict; |
|
20
|
|
|
|
|
84
|
|
|
20
|
|
|
|
|
803
|
|
2
|
20
|
|
|
20
|
|
116
|
use warnings; |
|
20
|
|
|
|
|
584
|
|
|
20
|
|
|
|
|
1213
|
|
3
|
|
|
|
|
|
|
package JSON::Schema::Draft201909::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.028'; |
8
|
|
|
|
|
|
|
|
9
|
20
|
|
|
20
|
|
412
|
use 5.016; |
|
20
|
|
|
|
|
76
|
|
10
|
20
|
|
|
20
|
|
153
|
no if "$]" >= 5.031009, feature => 'indirect'; |
|
20
|
|
|
|
|
132
|
|
|
20
|
|
|
|
|
326
|
|
11
|
20
|
|
|
20
|
|
1069
|
no if "$]" >= 5.033001, feature => 'multidimensional'; |
|
20
|
|
|
|
|
55
|
|
|
20
|
|
|
|
|
206
|
|
12
|
20
|
|
|
20
|
|
1046
|
no if "$]" >= 5.033006, feature => 'bareword_filehandles'; |
|
20
|
|
|
|
|
51
|
|
|
20
|
|
|
|
|
120
|
|
13
|
20
|
|
|
20
|
|
943
|
use strictures 2; |
|
20
|
|
|
|
|
268
|
|
|
20
|
|
|
|
|
815
|
|
14
|
20
|
|
|
20
|
|
3966
|
use JSON::Schema::Draft201909::Utilities qw(jsonp assert_keyword_type); |
|
20
|
|
|
|
|
45
|
|
|
20
|
|
|
|
|
1412
|
|
15
|
20
|
|
|
20
|
|
137
|
use Moo::Role; |
|
20
|
|
|
|
|
44
|
|
|
20
|
|
|
|
|
183
|
|
16
|
20
|
|
|
20
|
|
11682
|
use namespace::clean; |
|
20
|
|
|
|
|
71
|
|
|
20
|
|
|
|
|
154
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
requires qw(vocabulary keywords); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub traverse { |
21
|
0
|
|
|
0
|
1
|
0
|
my ($self, $schema, $state) = @_; |
22
|
0
|
|
|
|
|
0
|
$state->{evaluator}->_traverse($schema, $state); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub traverse_subschema { |
26
|
1715
|
|
|
1715
|
1
|
4066
|
my ($self, $schema, $state) = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$state->{evaluator}->_traverse($schema->{$state->{keyword}}, |
29
|
1715
|
|
|
|
|
18537
|
+{ %$state, schema_path => $state->{schema_path}.'/'.$state->{keyword} }); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub traverse_array_schemas { |
33
|
958
|
|
|
958
|
1
|
2217
|
my ($self, $schema, $state) = @_; |
34
|
|
|
|
|
|
|
|
35
|
958
|
50
|
|
|
|
3058
|
return if not assert_keyword_type($state, $schema, 'array'); |
36
|
958
|
50
|
|
|
|
1712
|
return E($state, '%s array is empty', $state->{keyword}) if not @{$schema->{$state->{keyword}}}; |
|
958
|
|
|
|
|
2796
|
|
37
|
|
|
|
|
|
|
|
38
|
958
|
|
|
|
|
1902
|
foreach my $idx (0 .. $#{$schema->{$state->{keyword}}}) { |
|
958
|
|
|
|
|
3291
|
|
39
|
|
|
|
|
|
|
$state->{evaluator}->_traverse($schema->{$state->{keyword}}[$idx], |
40
|
1653
|
|
|
|
|
18514
|
+{ %$state, schema_path => $state->{schema_path}.'/'.$state->{keyword}.'/'.$idx }); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub traverse_object_schemas { |
45
|
1178
|
|
|
1178
|
1
|
3272
|
my ($self, $schema, $state) = @_; |
46
|
|
|
|
|
|
|
|
47
|
1178
|
50
|
|
|
|
3943
|
return if not assert_keyword_type($state, $schema, 'object'); |
48
|
|
|
|
|
|
|
|
49
|
1178
|
|
|
|
|
2551
|
foreach my $property (sort keys %{$schema->{$state->{keyword}}}) { |
|
1178
|
|
|
|
|
5491
|
|
50
|
|
|
|
|
|
|
$state->{evaluator}->_traverse($schema->{$state->{keyword}}{$property}, |
51
|
1707
|
|
|
|
|
11127
|
+{ %$state, schema_path => jsonp($state->{schema_path}, $state->{keyword}, $property) }); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub traverse_property_schema { |
56
|
380
|
|
|
380
|
1
|
1123
|
my ($self, $schema, $state, $property) = @_; |
57
|
|
|
|
|
|
|
|
58
|
380
|
50
|
|
|
|
1184
|
return if not assert_keyword_type($state, $schema, 'object'); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$state->{evaluator}->_traverse($schema->{$state->{keyword}}{$property}, |
61
|
380
|
|
|
|
|
2211
|
+{ %$state, schema_path => jsonp($state->{schema_path}, $state->{keyword}, $property) }); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub eval { |
65
|
4325
|
|
|
4325
|
1
|
19470
|
my ($self, $data, $schema, $state) = @_; |
66
|
4325
|
|
|
|
|
16271
|
$state->{evaluator}->_eval($data, $schema, $state); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=pod |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=encoding UTF-8 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
JSON::Schema::Draft201909::Vocabulary - Base role for JSON Schema vocabulary classes |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 VERSION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
version 0.028 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SYNOPSIS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
package MyApp::Vocabulary::Awesome; |
88
|
|
|
|
|
|
|
use Moo::Role; |
89
|
|
|
|
|
|
|
with 'JSON::Schema::Draft201909::Vocabulary'; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 DESCRIPTION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This package is the role which all all vocabulary classes for L<JSON::Schema::Draft201909> |
94
|
|
|
|
|
|
|
must compose, describing the basic structure expected of a vocabulary class. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
User-defined custom vocabularies are not supported at this time. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 METHODS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=for stopwords schema subschema |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 vocabulary |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
The canonical URI describing the vocabulary, as described in |
107
|
|
|
|
|
|
|
L<JSON Schema Core Meta-specification, section 8.1.2|https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.8.1.2>. Must be implemented by the composing class. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 keywords |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The list of keywords defined by the vocabulary. Must be implemented by the composing class. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 traverse |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Traverses a subschema. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 traverse_subschema |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Recursively traverses the schema at the current keyword. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 traverse_array_schemas |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Recursively traverses the list of subschemas at the current keyword. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 traverse_object_schemas |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Recursively traverses the (subschema) values of the object at the current keyword. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 traverse_property_schema |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Recursively traverses the subschema under one property of the object at the current keyword. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 eval |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Evaluates a subschema. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SUPPORT |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Bugs may be submitted through L<https://github.com/karenetheridge/JSON-Schema-Draft201909/issues>. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
I am also usually active on irc, as 'ether' at C<irc.perl.org> and C<irc.libera.chat>. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Karen Etheridge. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
152
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |