Filename | /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm |
Statements | Executed 423865 statements in 449ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
35279 | 1 | 1 | 290ms | 781ms | _eval_keyword_type | JSON::Schema::Modern::Vocabulary::Validation::
4781 | 1 | 1 | 42.1ms | 395ms | _eval_keyword_required | JSON::Schema::Modern::Vocabulary::Validation::
1527 | 1 | 1 | 15.9ms | 197ms | _eval_keyword_enum | JSON::Schema::Modern::Vocabulary::Validation::
1372 | 1 | 1 | 12.1ms | 51.9ms | _traverse_keyword_type | JSON::Schema::Modern::Vocabulary::Validation::
1203 | 1 | 1 | 11.3ms | 239ms | _eval_keyword_const | JSON::Schema::Modern::Vocabulary::Validation::
1388 | 1 | 1 | 8.70ms | 74.5ms | _eval_keyword_uniqueItems | JSON::Schema::Modern::Vocabulary::Validation::
1232 | 1 | 1 | 6.50ms | 9.43ms | _eval_keyword_minItems | JSON::Schema::Modern::Vocabulary::Validation::
270 | 1 | 1 | 2.84ms | 67.0ms | _traverse_keyword_required | JSON::Schema::Modern::Vocabulary::Validation::
485 | 1 | 1 | 2.71ms | 3.54ms | _eval_keyword_minProperties | JSON::Schema::Modern::Vocabulary::Validation::
261 | 1 | 1 | 1.92ms | 4.98ms | _eval_keyword_pattern | JSON::Schema::Modern::Vocabulary::Validation::
21 | 1 | 1 | 738µs | 1.04ms | _traverse_keyword_minimum | JSON::Schema::Modern::Vocabulary::Validation::
261 | 1 | 1 | 627µs | 627µs | CORE:match (opcode) | JSON::Schema::Modern::Vocabulary::Validation::
87 | 8 | 1 | 446µs | 1.44ms | _assert_non_negative_integer | JSON::Schema::Modern::Vocabulary::Validation::
79 | 1 | 1 | 430µs | 1.31ms | _eval_keyword_minimum | JSON::Schema::Modern::Vocabulary::Validation::
261 | 1 | 1 | 413µs | 413µs | CORE:regcomp (opcode) | JSON::Schema::Modern::Vocabulary::Validation::
69 | 1 | 1 | 406µs | 3.78ms | _traverse_keyword_pattern | JSON::Schema::Modern::Vocabulary::Validation::
59 | 1 | 1 | 312µs | 637µs | _traverse_keyword_enum | JSON::Schema::Modern::Vocabulary::Validation::
50 | 1 | 1 | 250µs | 1.10ms | _traverse_keyword_minProperties | JSON::Schema::Modern::Vocabulary::Validation::
30 | 3 | 1 | 115µs | 422µs | _assert_number | JSON::Schema::Modern::Vocabulary::Validation::
92 | 1 | 1 | 113µs | 113µs | _traverse_keyword_const | JSON::Schema::Modern::Vocabulary::Validation::
15 | 1 | 1 | 93µs | 123µs | _eval_keyword_maxProperties | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 83µs | 99µs | _traverse_keyword_dependentRequired | JSON::Schema::Modern::Vocabulary::Validation::
14 | 1 | 1 | 63µs | 288µs | _traverse_keyword_minItems | JSON::Schema::Modern::Vocabulary::Validation::
8 | 1 | 1 | 42µs | 152µs | _traverse_keyword_maximum | JSON::Schema::Modern::Vocabulary::Validation::
8 | 1 | 1 | 41µs | 185µs | _traverse_keyword_maxLength | JSON::Schema::Modern::Vocabulary::Validation::
3 | 1 | 1 | 34µs | 94µs | _traverse_keyword_uniqueItems | JSON::Schema::Modern::Vocabulary::Validation::
8 | 1 | 1 | 30µs | 140µs | _traverse_keyword_minLength | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 28µs | 33µs | BEGIN@1.311 | Module::Runtime::
1 | 1 | 1 | 21µs | 47µs | BEGIN@13 | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 18µs | 866µs | BEGIN@11 | JSON::Schema::Modern::Vocabulary::Validation::
3 | 1 | 1 | 17µs | 76µs | _traverse_keyword_maxProperties | JSON::Schema::Modern::Vocabulary::Validation::
2 | 1 | 1 | 16µs | 51µs | _traverse_keyword_maxContains | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 12µs | 46µs | BEGIN@17 | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 11µs | 11µs | BEGIN@9 | JSON::Schema::Modern::Vocabulary::Validation::
2 | 2 | 1 | 10µs | 10µs | keywords | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 9µs | 20µs | BEGIN@15 | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 9µs | 29µs | BEGIN@18 | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 8µs | 107µs | BEGIN@12 | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 8µs | 25µs | BEGIN@14 | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 8µs | 15µs | BEGIN@16 | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 8µs | 8.61ms | BEGIN@19 | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 8µs | 49µs | BEGIN@2.312 | Module::Runtime::
1 | 1 | 1 | 7µs | 45µs | BEGIN@20 | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 6µs | 389µs | BEGIN@10 | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 6µs | 222µs | BEGIN@21 | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 4µs | 13µs | _traverse_keyword_maxItems | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 3µs | 14µs | _traverse_keyword_exclusiveMinimum | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 2µs | 10µs | _traverse_keyword_minContains | JSON::Schema::Modern::Vocabulary::Validation::
5 | 1 | 1 | 2µs | 2µs | evaluation_order | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 2µs | 2µs | vocabulary | JSON::Schema::Modern::Vocabulary::Validation::
1 | 1 | 1 | 0s | 0s | CORE:sort (opcode) | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | __ANON__[:263] | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | __ANON__[:49] | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | __ANON__[:56] | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | __ANON__[:67] | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | __ANON__[:85] | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _eval_keyword_dependentRequired | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _eval_keyword_exclusiveMaximum | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _eval_keyword_exclusiveMinimum | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _eval_keyword_maxContains | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _eval_keyword_maxItems | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _eval_keyword_maxLength | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _eval_keyword_maximum | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _eval_keyword_minContains | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _eval_keyword_minLength | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _eval_keyword_multipleOf | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _traverse_keyword_exclusiveMaximum | JSON::Schema::Modern::Vocabulary::Validation::
0 | 0 | 0 | 0s | 0s | _traverse_keyword_multipleOf | JSON::Schema::Modern::Vocabulary::Validation::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 2 | 36µs | 2 | 38µs | # spent 33µs (28+5) within Module::Runtime::BEGIN@1.311 which was called:
# once (28µs+5µs) by Module::Runtime::require_module at line 1 # spent 33µs making 1 call to Module::Runtime::BEGIN@1.311
# spent 5µs making 1 call to strict::import |
2 | 2 | 65µs | 2 | 90µs | # spent 49µs (8+41) within Module::Runtime::BEGIN@2.312 which was called:
# once (8µs+41µs) by Module::Runtime::require_module at line 2 # spent 49µs making 1 call to Module::Runtime::BEGIN@2.312
# spent 41µs making 1 call to warnings::import |
3 | package JSON::Schema::Modern::Vocabulary::Validation; | ||||
4 | # vim: set ts=8 sts=2 sw=2 tw=100 et : | ||||
5 | # ABSTRACT: Implementation of the JSON Schema Validation vocabulary | ||||
6 | |||||
7 | 1 | 0s | our $VERSION = '0.559'; | ||
8 | |||||
9 | 2 | 31µs | 1 | 11µs | # spent 11µs within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@9 which was called:
# once (11µs+0s) by Module::Runtime::require_module at line 9 # spent 11µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@9 |
10 | 2 | 34µs | 2 | 772µs | # spent 389µs (6+383) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@10 which was called:
# once (6µs+383µs) by Module::Runtime::require_module at line 10 # spent 389µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@10
# spent 383µs making 1 call to Moo::import |
11 | 3 | 52µs | 3 | 1.71ms | # spent 866µs (18+848) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@11 which was called:
# once (18µs+848µs) by Module::Runtime::require_module at line 11 # spent 866µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@11
# spent 832µs making 1 call to strictures::import
# spent 16µs making 1 call to strictures::VERSION |
12 | 2 | 54µs | 2 | 206µs | # spent 107µs (8+99) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@12 which was called:
# once (8µs+99µs) by Module::Runtime::require_module at line 12 # spent 107µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@12
# spent 99µs making 1 call to experimental::import |
13 | 2 | 32µs | 2 | 50µs | # spent 47µs (21+26) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@13 which was called:
# once (21µs+26µs) by Module::Runtime::require_module at line 13 # spent 47µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@13
# spent 3µs making 1 call to if::import |
14 | 2 | 20µs | 2 | 27µs | # spent 25µs (8+17) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@14 which was called:
# once (8µs+17µs) by Module::Runtime::require_module at line 14 # spent 25µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@14
# spent 2µs making 1 call to if::unimport |
15 | 2 | 19µs | 2 | 21µs | # spent 20µs (9+11) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@15 which was called:
# once (9µs+11µs) by Module::Runtime::require_module at line 15 # spent 20µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@15
# spent 1µs making 1 call to if::unimport |
16 | 2 | 14µs | 2 | 15µs | # spent 15µs (8+7) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@16 which was called:
# once (8µs+7µs) by Module::Runtime::require_module at line 16 # spent 15µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@16
# spent 0s making 1 call to if::unimport |
17 | 2 | 22µs | 2 | 57µs | # spent 46µs (12+34) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@17 which was called:
# once (12µs+34µs) by Module::Runtime::require_module at line 17 # spent 46µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@17
# spent 11µs making 1 call to List::Util::import |
18 | 3 | 36µs | 3 | 49µs | # spent 29µs (9+20) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@18 which was called:
# once (9µs+20µs) by Module::Runtime::require_module at line 18 # spent 29µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@18
# spent 12µs making 1 call to Exporter::import
# spent 8µs making 1 call to UNIVERSAL::VERSION |
19 | 2 | 45µs | 2 | 8.61ms | # spent 8.61ms (8µs+8.60) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@19 which was called:
# once (8µs+8.60ms) by Module::Runtime::require_module at line 19 # spent 8.61ms making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@19
# spent 1µs making 1 call to if::import |
20 | 2 | 19µs | 2 | 83µs | # spent 45µs (7+38) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@20 which was called:
# once (7µs+38µs) by Module::Runtime::require_module at line 20 # spent 45µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@20
# spent 38µs making 1 call to Exporter::import |
21 | 2 | 2.41ms | 2 | 438µs | # spent 222µs (6+216) within JSON::Schema::Modern::Vocabulary::Validation::BEGIN@21 which was called:
# once (6µs+216µs) by Module::Runtime::require_module at line 21 # spent 222µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::BEGIN@21
# spent 216µs making 1 call to namespace::clean::import |
22 | |||||
23 | 1 | 18µs | 1 | 586µs | with 'JSON::Schema::Modern::Vocabulary'; # spent 586µs making 1 call to Moo::with |
24 | |||||
25 | # spent 2µs within JSON::Schema::Modern::Vocabulary::Validation::vocabulary which was called:
# once (2µs+0s) by JSON::Schema::Modern::__ANON__[/Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm:709] at line 705 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm | ||||
26 | 1 | 2µs | 'https://json-schema.org/draft/2019-09/vocab/validation' => 'draft2019-09', | ||
27 | 'https://json-schema.org/draft/2020-12/vocab/validation' => 'draft2020-12'; | ||||
28 | } | ||||
29 | |||||
30 | 5 | 5µs | # spent 2µs within JSON::Schema::Modern::Vocabulary::Validation::evaluation_order which was called 5 times, avg 400ns/call:
# 5 times (2µs+0s) by JSON::Schema::Modern::Vocabulary::Core::CORE:sort at line 337 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 400ns/call | ||
31 | |||||
32 | 6 | 2µs | # spent 10µs within JSON::Schema::Modern::Vocabulary::Validation::keywords which was called 2 times, avg 5µs/call:
# once (7µs+0s) by JSON::Schema::Modern::_eval_subschema at line 572 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm
# once (3µs+0s) by JSON::Schema::Modern::_traverse_subschema at line 480 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm | ||
33 | return ( | ||||
34 | 2 | 10µs | qw(type enum const | ||
35 | multipleOf maximum exclusiveMaximum minimum exclusiveMinimum | ||||
36 | maxLength minLength pattern | ||||
37 | maxItems minItems uniqueItems), | ||||
38 | $spec_version ne 'draft7' ? qw(maxContains minContains) : (), | ||||
39 | qw(maxProperties minProperties required), | ||||
40 | $spec_version ne 'draft7' ? 'dependentRequired' : (), | ||||
41 | ); | ||||
42 | } | ||||
43 | |||||
44 | 5488 | 973µs | # spent 51.9ms (12.1+39.7) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type which was called 1372 times, avg 38µs/call:
# 1372 times (12.1ms+39.7ms) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 38µs/call | ||
45 | 1372 | 2.34ms | if (is_plain_arrayref($schema->{type})) { | ||
46 | 76 | 48µs | return E($state, 'type array is empty') if not $schema->{type}->@*; | ||
47 | 76 | 62µs | foreach my $type ($schema->{type}->@*) { | ||
48 | return E($state, 'unrecognized type "%s"', $type//'<null>') | ||||
49 | 692 | 656µs | 158 | 222µs | if not any { ($type//'') eq $_ } qw(null boolean object array string number integer); # spent 222µs making 158 calls to List::Util::any, avg 1µs/call |
50 | } | ||||
51 | 76 | 95µs | 76 | 2.65ms | return E($state, '"type" values are not unique') if not is_elements_unique($schema->{type}); # spent 2.65ms making 76 calls to JSON::Schema::Modern::Utilities::is_elements_unique, avg 35µs/call |
52 | } | ||||
53 | else { | ||||
54 | 1296 | 1.41ms | 1296 | 33.5ms | return if not assert_keyword_type($state, $schema, 'string'); # spent 33.5ms making 1296 calls to JSON::Schema::Modern::Utilities::assert_keyword_type, avg 26µs/call |
55 | return E($state, 'unrecognized type "%s"', $schema->{type}//'<null>') | ||||
56 | 6393 | 7.69ms | 1296 | 3.38ms | if not any { ($schema->{type}//'') eq $_ } qw(null boolean object array string number integer); # spent 3.38ms making 1296 calls to List::Util::any, avg 3µs/call |
57 | } | ||||
58 | 1372 | 2.04ms | return 1; | ||
59 | } | ||||
60 | |||||
61 | 176395 | 28.8ms | # spent 781ms (290+491) within JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type which was called 35279 times, avg 22µs/call:
# 35279 times (290ms+491ms) by JSON::Schema::Modern::_eval_subschema at line 587 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 22µs/call | ||
62 | 35279 | 39.7ms | 35279 | 150ms | my $type = get_type($data); # spent 150ms making 35279 calls to JSON::Schema::Modern::Utilities::get_type, avg 4µs/call |
63 | 35279 | 16.6ms | if (is_plain_arrayref($schema->{type})) { | ||
64 | return 1 if any { | ||||
65 | $type eq $_ or ($_ eq 'number' and $type eq 'integer') | ||||
66 | 26478 | 151ms | or ($_ eq 'boolean' and $state->{scalarref_booleans} and $type eq 'reference to SCALAR') | ||
67 | 23004 | 65.1ms | 23004 | 68.6ms | } $schema->{type}->@*; # spent 68.6ms making 23004 calls to List::Util::any, avg 3µs/call |
68 | return E($state, 'got %s, not one of %s', $type, join(', ', $schema->{type}->@*)); | ||||
69 | } | ||||
70 | else { | ||||
71 | return 1 if $type eq $schema->{type} or ($schema->{type} eq 'number' and $type eq 'integer') | ||||
72 | 12275 | 23.8ms | or ($schema->{type} eq 'boolean' and $state->{scalarref_booleans} and $type eq 'reference to SCALAR'); | ||
73 | 1105 | 4.15ms | 1105 | 272ms | return E($state, 'got %s, not %s', $type, $schema->{type}); # spent 272ms making 1105 calls to JSON::Schema::Modern::Utilities::E, avg 247µs/call |
74 | } | ||||
75 | } | ||||
76 | |||||
77 | 236 | 39µs | # spent 637µs (312+325) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_enum which was called 59 times, avg 11µs/call:
# 59 times (312µs+325µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 11µs/call | ||
78 | 59 | 80µs | 59 | 325µs | return if not assert_keyword_type($state, $schema, 'array'); # spent 325µs making 59 calls to JSON::Schema::Modern::Utilities::assert_keyword_type, avg 6µs/call |
79 | 59 | 99µs | return 1; | ||
80 | } | ||||
81 | |||||
82 | 7635 | 2.27ms | # spent 197ms (15.9+181) within JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_enum which was called 1527 times, avg 129µs/call:
# 1527 times (15.9ms+181ms) by JSON::Schema::Modern::_eval_subschema at line 587 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 129µs/call | ||
83 | 3054 | 834µs | my @s; my $idx = 0; | ||
84 | 1527 | 1.96ms | my %s = ( scalarref_booleans => $state->{scalarref_booleans} ); | ||
85 | 8983 | 25.7ms | 8983 | 309ms | return 1 if any { is_equal($data, $_, $s[$idx++] = {%s}) } $schema->{enum}->@*; # spent 165ms making 1527 calls to List::Util::any, avg 108µs/call
# spent 144ms making 7456 calls to JSON::Schema::Modern::Utilities::is_equal, avg 19µs/call |
86 | return E($state, 'value does not match' | ||||
87 | .(!(grep $_->{path}, @s) ? '' | ||||
88 | 66 | 494µs | 66 | 16.5ms | : ' (differences start '.join(', ', map 'from item #'.$_.' at "'.$s[$_]->{path}.'"', 0..$#s).')')); # spent 16.5ms making 66 calls to JSON::Schema::Modern::Utilities::E, avg 250µs/call |
89 | } | ||||
90 | |||||
91 | 92 | 135µs | # spent 113µs within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_const which was called 92 times, avg 1µs/call:
# 92 times (113µs+0s) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 1µs/call | ||
92 | |||||
93 | 6015 | 1.29ms | # spent 239ms (11.3+228) within JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const which was called 1203 times, avg 199µs/call:
# 1203 times (11.3ms+228ms) by JSON::Schema::Modern::_eval_subschema at line 587 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 199µs/call | ||
94 | 1203 | 1.31ms | my %s = ( scalarref_booleans => $state->{scalarref_booleans} ); | ||
95 | 1203 | 3.81ms | 1203 | 37.4ms | return 1 if is_equal($data, $schema->{const}, my $s = { scalarref_booleans => $state->{scalarref_booleans} }); # spent 37.4ms making 1203 calls to JSON::Schema::Modern::Utilities::is_equal, avg 31µs/call |
96 | return E($state, 'value does not match' | ||||
97 | 795 | 3.65ms | 795 | 191ms | .($s->{path} ? ' (differences start at "'.$s->{path}.'")' : '')); # spent 191ms making 795 calls to JSON::Schema::Modern::Utilities::E, avg 240µs/call |
98 | } | ||||
99 | |||||
100 | sub _traverse_keyword_multipleOf ($self, $schema, $state) { | ||||
101 | return if not assert_keyword_type($state, $schema, 'number'); | ||||
102 | return E($state, 'multipleOf value is not a positive number') if $schema->{multipleOf} <= 0; | ||||
103 | return 1; | ||||
104 | } | ||||
105 | |||||
106 | sub _eval_keyword_multipleOf ($self, $data, $schema, $state) { | ||||
107 | return 1 if not is_type('number', $data); | ||||
108 | |||||
109 | # if either value is a float, use the bignum library for the calculation for an accurate remainder | ||||
110 | if (ref($data) =~ /^Math::Big(?:Int|Float)$/ or ref($schema->{multipleOf}) =~ /^Math::Big(?:Int|Float)$/) { | ||||
111 | $data = ref($data) =~ /^Math::Big(?:Int|Float)$/ ? $data->copy : Math::BigFloat->new($data); | ||||
112 | my $divisor = ref($schema->{multipleOf}) =~ /^Math::Big(?:Int|Float)$/ ? $schema->{multipleOf} : Math::BigFloat->new($schema->{multipleOf}); | ||||
113 | my ($quotient, $remainder) = $data->bdiv($divisor); | ||||
114 | return E($state, 'overflow while calculating quotient') if $quotient->is_inf; | ||||
115 | return 1 if $remainder == 0; | ||||
116 | } | ||||
117 | else { | ||||
118 | my $quotient = $data / $schema->{multipleOf}; | ||||
119 | return E($state, 'overflow while calculating quotient') | ||||
120 | if "$]" >= 5.022 ? isinf($quotient) : $quotient =~ /^-?Inf$/i; | ||||
121 | return 1 if int($quotient) == $quotient; | ||||
122 | } | ||||
123 | |||||
124 | return E($state, 'value is not a multiple of %s', sprintf_num($schema->{multipleOf})); | ||||
125 | } | ||||
126 | |||||
127 | 8 | 29µs | 8 | 110µs | # spent 152µs (42+110) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maximum which was called 8 times, avg 19µs/call:
# 8 times (42µs+110µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 19µs/call # spent 110µs making 8 calls to JSON::Schema::Modern::Vocabulary::Validation::_assert_number, avg 14µs/call |
128 | |||||
129 | sub _eval_keyword_maximum ($self, $data, $schema, $state) { | ||||
130 | return 1 if not is_type('number', $data); | ||||
131 | return 1 if $data <= $schema->{maximum}; | ||||
132 | return E($state, 'value is larger than %s', sprintf_num($schema->{maximum})); | ||||
133 | } | ||||
134 | |||||
135 | sub _traverse_keyword_exclusiveMaximum { shift->_assert_number(@_) } | ||||
136 | |||||
137 | sub _eval_keyword_exclusiveMaximum ($self, $data, $schema, $state) { | ||||
138 | return 1 if not is_type('number', $data); | ||||
139 | return 1 if $data < $schema->{exclusiveMaximum}; | ||||
140 | return E($state, 'value is equal to or larger than %s', sprintf_num($schema->{exclusiveMaximum})); | ||||
141 | } | ||||
142 | |||||
143 | 21 | 734µs | 21 | 301µs | # spent 1.04ms (738µs+301µs) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minimum which was called 21 times, avg 49µs/call:
# 21 times (738µs+301µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 49µs/call # spent 301µs making 21 calls to JSON::Schema::Modern::Vocabulary::Validation::_assert_number, avg 14µs/call |
144 | |||||
145 | 395 | 67µs | # spent 1.31ms (430µs+878µs) within JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minimum which was called 79 times, avg 17µs/call:
# 79 times (430µs+878µs) by JSON::Schema::Modern::_eval_subschema at line 587 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 17µs/call | ||
146 | 79 | 159µs | 79 | 878µs | return 1 if not is_type('number', $data); # spent 878µs making 79 calls to JSON::Schema::Modern::Utilities::is_type, avg 11µs/call |
147 | 79 | 205µs | return 1 if $data >= $schema->{minimum}; | ||
148 | return E($state, 'value is smaller than %s', sprintf_num($schema->{minimum})); | ||||
149 | } | ||||
150 | |||||
151 | 1 | 5µs | 1 | 11µs | # spent 14µs (3+11) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_exclusiveMinimum which was called:
# once (3µs+11µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm # spent 11µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::_assert_number |
152 | |||||
153 | sub _eval_keyword_exclusiveMinimum ($self, $data, $schema, $state) { | ||||
154 | return 1 if not is_type('number', $data); | ||||
155 | return 1 if $data > $schema->{exclusiveMinimum}; | ||||
156 | return E($state, 'value is equal to or smaller than %s', sprintf_num($schema->{exclusiveMinimum})); | ||||
157 | } | ||||
158 | |||||
159 | 8 | 49µs | 8 | 144µs | # spent 185µs (41+144) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxLength which was called 8 times, avg 23µs/call:
# 8 times (41µs+144µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 23µs/call # spent 144µs making 8 calls to JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer, avg 18µs/call |
160 | |||||
161 | sub _eval_keyword_maxLength ($self, $data, $schema, $state) { | ||||
162 | return 1 if not is_type('string', $data); | ||||
163 | return 1 if length($data) <= $schema->{maxLength}; | ||||
164 | return E($state, 'length is greater than %d', $schema->{maxLength}); | ||||
165 | } | ||||
166 | |||||
167 | 8 | 47µs | 8 | 110µs | # spent 140µs (30+110) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minLength which was called 8 times, avg 18µs/call:
# 8 times (30µs+110µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 18µs/call # spent 110µs making 8 calls to JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer, avg 14µs/call |
168 | |||||
169 | sub _eval_keyword_minLength ($self, $data, $schema, $state) { | ||||
170 | |||||
171 | return 1 if not is_type('string', $data); | ||||
172 | return 1 if length($data) >= $schema->{minLength}; | ||||
173 | return E($state, 'length is less than %d', $schema->{minLength}); | ||||
174 | } | ||||
175 | |||||
176 | 276 | 47µs | # spent 3.78ms (406µs+3.37) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern which was called 69 times, avg 55µs/call:
# 69 times (406µs+3.37ms) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 55µs/call | ||
177 | return if not assert_keyword_type($state, $schema, 'string') | ||||
178 | 69 | 161µs | 138 | 3.37ms | or not assert_pattern($state, $schema->{pattern}); # spent 2.57ms making 69 calls to JSON::Schema::Modern::Utilities::assert_pattern, avg 37µs/call
# spent 799µs making 69 calls to JSON::Schema::Modern::Utilities::assert_keyword_type, avg 12µs/call |
179 | 69 | 108µs | return 1; | ||
180 | } | ||||
181 | |||||
182 | 1305 | 256µs | # spent 4.98ms (1.92+3.06) within JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_pattern which was called 261 times, avg 19µs/call:
# 261 times (1.92ms+3.06ms) by JSON::Schema::Modern::_eval_subschema at line 587 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 19µs/call | ||
183 | 261 | 285µs | 261 | 2.01ms | return 1 if not is_type('string', $data); # spent 2.01ms making 261 calls to JSON::Schema::Modern::Utilities::is_type, avg 8µs/call |
184 | |||||
185 | 261 | 2.24ms | 522 | 1.04ms | return 1 if $data =~ m/$schema->{pattern}/; # spent 627µs making 261 calls to JSON::Schema::Modern::Vocabulary::Validation::CORE:match, avg 2µs/call
# spent 413µs making 261 calls to JSON::Schema::Modern::Vocabulary::Validation::CORE:regcomp, avg 2µs/call |
186 | return E($state, 'pattern does not match'); | ||||
187 | } | ||||
188 | |||||
189 | 1 | 4µs | 1 | 9µs | # spent 13µs (4+9) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxItems which was called:
# once (4µs+9µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm # spent 9µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer |
190 | |||||
191 | sub _eval_keyword_maxItems ($self, $data, $schema, $state) { | ||||
192 | return 1 if not is_type('array', $data); | ||||
193 | return 1 if @$data <= $schema->{maxItems}; | ||||
194 | return E($state, 'more than %d item%s', $schema->{maxItems}, $schema->{maxItems} > 1 ? 's' : ''); | ||||
195 | } | ||||
196 | |||||
197 | 14 | 48µs | 14 | 225µs | # spent 288µs (63+225) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minItems which was called 14 times, avg 21µs/call:
# 14 times (63µs+225µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 21µs/call # spent 225µs making 14 calls to JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer, avg 16µs/call |
198 | |||||
199 | 6160 | 1.63ms | # spent 9.43ms (6.50+2.94) within JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minItems which was called 1232 times, avg 8µs/call:
# 1232 times (6.50ms+2.94ms) by JSON::Schema::Modern::_eval_subschema at line 587 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 8µs/call | ||
200 | 1232 | 3.37ms | 1232 | 2.94ms | return 1 if not is_type('array', $data); # spent 2.94ms making 1232 calls to JSON::Schema::Modern::Utilities::is_type, avg 2µs/call |
201 | 127 | 255µs | return 1 if @$data >= $schema->{minItems}; | ||
202 | return E($state, 'fewer than %d item%s', $schema->{minItems}, $schema->{minItems} > 1 ? 's' : ''); | ||||
203 | } | ||||
204 | |||||
205 | 12 | 4µs | # spent 94µs (34+60) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_uniqueItems which was called 3 times, avg 31µs/call:
# 3 times (34µs+60µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 31µs/call | ||
206 | 3 | 10µs | 3 | 60µs | return if not assert_keyword_type($state, $schema, 'boolean'); # spent 60µs making 3 calls to JSON::Schema::Modern::Utilities::assert_keyword_type, avg 20µs/call |
207 | 3 | 5µs | return 1; | ||
208 | } | ||||
209 | |||||
210 | 6940 | 1.93ms | # spent 74.5ms (8.70+65.8) within JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems which was called 1388 times, avg 54µs/call:
# 1388 times (8.70ms+65.8ms) by JSON::Schema::Modern::_eval_subschema at line 587 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 54µs/call | ||
211 | 1388 | 3.21ms | 1388 | 1.90ms | return 1 if not is_type('array', $data); # spent 1.90ms making 1388 calls to JSON::Schema::Modern::Utilities::is_type, avg 1µs/call |
212 | 283 | 1.03ms | 283 | 775µs | return 1 if not $schema->{uniqueItems}; # spent 775µs making 283 calls to JSON::PP::Boolean::__ANON__[JSON/PP/Boolean.pm:8], avg 3µs/call |
213 | 283 | 1.06ms | 283 | 63.1ms | return 1 if is_elements_unique($data, my $equal_indices = []); # spent 63.1ms making 283 calls to JSON::Schema::Modern::Utilities::is_elements_unique, avg 223µs/call |
214 | return E($state, 'items at indices %d and %d are not unique', @$equal_indices); | ||||
215 | } | ||||
216 | |||||
217 | # Note: no effort is made to check if the 'contains' keyword has been disabled via its vocabulary. | ||||
218 | 2 | 10µs | 2 | 35µs | # spent 51µs (16+35) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxContains which was called 2 times, avg 26µs/call:
# 2 times (16µs+35µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 26µs/call # spent 35µs making 2 calls to JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer, avg 18µs/call |
219 | |||||
220 | sub _eval_keyword_maxContains ($self, $data, $schema, $state) { | ||||
221 | return 1 if not exists $state->{_num_contains}; | ||||
222 | return 1 if not is_type('array', $data); | ||||
223 | |||||
224 | return E($state, 'contains too many matching items') | ||||
225 | if $state->{_num_contains} > $schema->{maxContains}; | ||||
226 | |||||
227 | return 1; | ||||
228 | } | ||||
229 | |||||
230 | 1 | 2µs | 1 | 8µs | # spent 10µs (2+8) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minContains which was called:
# once (2µs+8µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm # spent 8µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer |
231 | |||||
232 | sub _eval_keyword_minContains ($self, $data, $schema, $state) { | ||||
233 | return 1 if not exists $state->{_num_contains}; | ||||
234 | return 1 if not is_type('array', $data); | ||||
235 | |||||
236 | return E($state, 'contains too few matching items') | ||||
237 | if $state->{_num_contains} < $schema->{minContains}; | ||||
238 | |||||
239 | return 1; | ||||
240 | } | ||||
241 | |||||
242 | 3 | 15µs | 3 | 59µs | # spent 76µs (17+59) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxProperties which was called 3 times, avg 25µs/call:
# 3 times (17µs+59µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 25µs/call # spent 59µs making 3 calls to JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer, avg 20µs/call |
243 | |||||
244 | 75 | 21µs | # spent 123µs (93+30) within JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_maxProperties which was called 15 times, avg 8µs/call:
# 15 times (93µs+30µs) by JSON::Schema::Modern::_eval_subschema at line 587 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 8µs/call | ||
245 | 15 | 23µs | 15 | 30µs | return 1 if not is_type('object', $data); # spent 30µs making 15 calls to JSON::Schema::Modern::Utilities::is_type, avg 2µs/call |
246 | 15 | 49µs | return 1 if keys %$data <= $schema->{maxProperties}; | ||
247 | return E($state, 'more than %d propert%s', $schema->{maxProperties}, | ||||
248 | $schema->{maxProperties} > 1 ? 'ies' : 'y'); | ||||
249 | } | ||||
250 | |||||
251 | 50 | 191µs | 50 | 846µs | # spent 1.10ms (250µs+846µs) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minProperties which was called 50 times, avg 22µs/call:
# 50 times (250µs+846µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 22µs/call # spent 846µs making 50 calls to JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer, avg 17µs/call |
252 | |||||
253 | 2425 | 534µs | # spent 3.54ms (2.71+829µs) within JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minProperties which was called 485 times, avg 7µs/call:
# 485 times (2.71ms+829µs) by JSON::Schema::Modern::_eval_subschema at line 587 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 7µs/call | ||
254 | 485 | 573µs | 485 | 829µs | return 1 if not is_type('object', $data); # spent 829µs making 485 calls to JSON::Schema::Modern::Utilities::is_type, avg 2µs/call |
255 | 485 | 1.41ms | return 1 if keys %$data >= $schema->{minProperties}; | ||
256 | return E($state, 'fewer than %d propert%s', $schema->{minProperties}, | ||||
257 | $schema->{minProperties} > 1 ? 'ies' : 'y'); | ||||
258 | } | ||||
259 | |||||
260 | 1080 | 222µs | # spent 67.0ms (2.84+64.2) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required which was called 270 times, avg 248µs/call:
# 270 times (2.84ms+64.2ms) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 248µs/call | ||
261 | 270 | 299µs | 270 | 1.40ms | return if not assert_keyword_type($state, $schema, 'array'); # spent 1.40ms making 270 calls to JSON::Schema::Modern::Utilities::assert_keyword_type, avg 5µs/call |
262 | return E($state, '"required" element is not a string') | ||||
263 | 1017 | 1.94ms | 1017 | 7.79ms | if any { !is_type('string', $_) } $schema->{required}->@*; # spent 4.55ms making 270 calls to List::Util::any, avg 17µs/call
# spent 3.23ms making 747 calls to JSON::Schema::Modern::Utilities::is_type, avg 4µs/call |
264 | 270 | 348µs | 270 | 58.2ms | return E($state, '"required" values are not unique') if not is_elements_unique($schema->{required}); # spent 58.2ms making 270 calls to JSON::Schema::Modern::Utilities::is_elements_unique, avg 216µs/call |
265 | 270 | 496µs | return 1; | ||
266 | } | ||||
267 | |||||
268 | 23905 | 4.35ms | # spent 395ms (42.1+353) within JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required which was called 4781 times, avg 83µs/call:
# 4781 times (42.1ms+353ms) by JSON::Schema::Modern::_eval_subschema at line 587 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 83µs/call | ||
269 | 4781 | 6.67ms | 4781 | 10.7ms | return 1 if not is_type('object', $data); # spent 10.7ms making 4781 calls to JSON::Schema::Modern::Utilities::is_type, avg 2µs/call |
270 | |||||
271 | 4781 | 11.9ms | my @missing = grep !exists $data->{$_}, $schema->{required}->@*; | ||
272 | 4781 | 6.93ms | return 1 if not @missing; | ||
273 | 1435 | 6.71ms | 1435 | 343ms | return E($state, 'missing propert%s: %s', @missing > 1 ? 'ies' : 'y', join(', ', @missing)); # spent 343ms making 1435 calls to JSON::Schema::Modern::Utilities::E, avg 239µs/call |
274 | } | ||||
275 | |||||
276 | 4 | 0s | # spent 99µs (83+16) within JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired which was called:
# once (83µs+16µs) by JSON::Schema::Modern::_traverse_subschema at line 492 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm | ||
277 | 1 | 1µs | 1 | 4µs | return if not assert_keyword_type($state, $schema, 'object'); # spent 4µs making 1 call to JSON::Schema::Modern::Utilities::assert_keyword_type |
278 | |||||
279 | 1 | 14µs | my $valid = 1; | ||
280 | 1 | 17µs | 1 | 0s | foreach my $property (sort keys $schema->{dependentRequired}->%*) { # spent 0s making 1 call to JSON::Schema::Modern::Vocabulary::Validation::CORE:sort |
281 | $valid = E({ %$state, _schema_path_suffix => $property }, 'value is not an array'), next | ||||
282 | 1 | 1µs | 1 | 3µs | if not is_type('array', $schema->{dependentRequired}{$property}); # spent 3µs making 1 call to JSON::Schema::Modern::Utilities::is_type |
283 | |||||
284 | 1 | 2µs | foreach my $index (0..$schema->{dependentRequired}{$property}->$#*) { | ||
285 | $valid = E({ %$state, _schema_path_suffix => [ $property, $index ] }, 'element #%d is not a string', $index) | ||||
286 | 1 | 2µs | 1 | 6µs | if not is_type('string', $schema->{dependentRequired}{$property}[$index]); # spent 6µs making 1 call to JSON::Schema::Modern::Utilities::is_type |
287 | } | ||||
288 | |||||
289 | $valid = E({ %$state, _schema_path_suffix => $property }, 'elements are not unique') | ||||
290 | 1 | 3µs | 1 | 3µs | if not is_elements_unique($schema->{dependentRequired}{$property}); # spent 3µs making 1 call to JSON::Schema::Modern::Utilities::is_elements_unique |
291 | } | ||||
292 | 1 | 4µs | return $valid; | ||
293 | } | ||||
294 | |||||
295 | sub _eval_keyword_dependentRequired ($self, $data, $schema, $state) { | ||||
296 | return 1 if not is_type('object', $data); | ||||
297 | |||||
298 | my $valid = 1; | ||||
299 | foreach my $property (sort keys $schema->{dependentRequired}->%*) { | ||||
300 | next if not exists $data->{$property}; | ||||
301 | |||||
302 | if (my @missing = grep !exists($data->{$_}), $schema->{dependentRequired}{$property}->@*) { | ||||
303 | $valid = E({ %$state, _schema_path_suffix => $property }, | ||||
304 | 'missing propert%s: %s', @missing > 1 ? 'ies' : 'y', join(', ', @missing)); | ||||
305 | } | ||||
306 | } | ||||
307 | |||||
308 | return 1 if $valid; | ||||
309 | return E($state, 'not all dependencies are satisfied'); | ||||
310 | } | ||||
311 | |||||
312 | 120 | 20µs | # spent 422µs (115+307) within JSON::Schema::Modern::Vocabulary::Validation::_assert_number which was called 30 times, avg 14µs/call:
# 21 times (80µs+221µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minimum at line 143, avg 14µs/call
# 8 times (31µs+79µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maximum at line 127, avg 14µs/call
# once (4µs+7µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_exclusiveMinimum at line 151 | ||
313 | 30 | 37µs | 30 | 307µs | return if not assert_keyword_type($state, $schema, 'number'); # spent 307µs making 30 calls to JSON::Schema::Modern::Utilities::assert_keyword_type, avg 10µs/call |
314 | 30 | 51µs | return 1; | ||
315 | } | ||||
316 | |||||
317 | 348 | 66µs | # spent 1.44ms (446µs+990µs) within JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer which was called 87 times, avg 17µs/call:
# 50 times (248µs+598µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minProperties at line 251, avg 17µs/call
# 14 times (63µs+162µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minItems at line 197, avg 16µs/call
# 8 times (67µs+77µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxLength at line 159, avg 18µs/call
# 8 times (34µs+76µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minLength at line 167, avg 14µs/call
# 3 times (18µs+41µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxProperties at line 242, avg 20µs/call
# 2 times (10µs+25µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxContains at line 218, avg 18µs/call
# once (3µs+6µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxItems at line 189
# once (3µs+5µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minContains at line 230 | ||
318 | 87 | 98µs | 87 | 990µs | return if not assert_keyword_type($state, $schema, 'integer'); # spent 990µs making 87 calls to JSON::Schema::Modern::Utilities::assert_keyword_type, avg 11µs/call |
319 | return E($state, '%s value is not a non-negative integer', $state->{keyword}) | ||||
320 | 87 | 80µs | if $schema->{$state->{keyword}} < 0; | ||
321 | 87 | 235µs | return 1; | ||
322 | } | ||||
323 | |||||
324 | 1 | 8µs | 1; | ||
325 | 1 | 49µs | 1 | 565µs | __END__ # spent 565µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |
# spent 627µs within JSON::Schema::Modern::Vocabulary::Validation::CORE:match which was called 261 times, avg 2µs/call:
# 261 times (627µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_pattern at line 185, avg 2µs/call | |||||
# spent 413µs within JSON::Schema::Modern::Vocabulary::Validation::CORE:regcomp which was called 261 times, avg 2µs/call:
# 261 times (413µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_pattern at line 185, avg 2µs/call | |||||
# spent 0s within JSON::Schema::Modern::Vocabulary::Validation::CORE:sort which was called:
# once (0s+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 280 |