|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package JSV::Keyword::Draft4::Type;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
44
 | 
 
 | 
 
 | 
  
44
  
 | 
 
 | 
29618
 | 
 use strict;  | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
76
 | 
    | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1015
 | 
    | 
| 
4
 | 
44
 | 
 
 | 
 
 | 
  
44
  
 | 
 
 | 
191
 | 
 use warnings;  | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
73
 | 
    | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1032
 | 
    | 
| 
5
 | 
44
 | 
 
 | 
 
 | 
  
44
  
 | 
 
 | 
188
 | 
 use parent qw(JSV::Keyword);  | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
69
 | 
    | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
195
 | 
    | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
7
 | 
44
 | 
 
 | 
 
 | 
  
44
  
 | 
 
 | 
1885
 | 
 use B;  | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
66
 | 
    | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1551
 | 
    | 
| 
8
 | 
44
 | 
 
 | 
 
 | 
  
44
  
 | 
 
 | 
188
 | 
 use JSON;  | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
82
 | 
    | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
321
 | 
    | 
| 
9
 | 
44
 | 
 
 | 
 
 | 
  
44
  
 | 
 
 | 
4885
 | 
 use List::Util qw(first);  | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
68
 | 
    | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2235
 | 
    | 
| 
10
 | 
44
 | 
 
 | 
 
 | 
  
44
  
 | 
 
 | 
228
 | 
 use Scalar::Util qw(blessed);  | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
67
 | 
    | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2049
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
12
 | 
44
 | 
 
 | 
 
 | 
  
44
  
 | 
 
 | 
185
 | 
 use JSV::Keyword qw(:constants);  | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
73
 | 
    | 
| 
 
 | 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
16088
 | 
    | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub instance_type() { INSTANCE_TYPE_ANY(); }  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub keyword() { "type" }  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub keyword_priority() { 10; }  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub validate {  | 
| 
19
 | 
864
 | 
 
 | 
 
 | 
  
864
  
 | 
  
0
  
 | 
1443
 | 
     my ($class, $context, $schema, $instance) = @_;  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
21
 | 
864
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2673
 | 
     my $keyword_value = $class->keyword_value($schema);  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
23
 | 
864
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
2019
 | 
     if (ref $keyword_value eq "ARRAY") {  | 
| 
24
 | 
13
 | 
  
100
  
 | 
 
 | 
  
23
  
 | 
 
 | 
115
 | 
         unless ( first { $class->validate_singular_type( $context, $_, $context->current_type, $instance ) } @$keyword_value ) {  | 
| 
 
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
74
 | 
    | 
| 
25
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
27
 | 
             $context->log_error("instance type doesn't match schema type list");  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     else {  | 
| 
29
 | 
851
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
2615
 | 
         unless ($class->validate_singular_type( $context, $keyword_value, $context->current_type, $instance )) {  | 
| 
30
 | 
167
 | 
 
 | 
 
 | 
 
 | 
 
 | 
581
 | 
             $context->log_error("instance type doesn't match schema type");  | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub validate_singular_type {  | 
| 
36
 | 
874
 | 
 
 | 
 
 | 
  
874
  
 | 
  
0
  
 | 
6177
 | 
     my ($class, $context, $schema_type, $given_type, $instance) = @_;  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
38
 | 
874
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
3715
 | 
     if ( $schema_type eq $given_type || ( $schema_type eq "number" && $given_type eq "integer") ) {  | 
| 
 
 | 
 
 | 
 
 | 
  
 66
  
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
39
 | 
536
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2206
 | 
         return 1;  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     else {  | 
| 
42
 | 
338
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
1086
 | 
         if ( $given_type eq "number_or_string" ) {  | 
| 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
43
 | 
27
 | 
  
100
  
 | 
  
 66
  
 | 
 
 | 
 
 | 
190
 | 
             return 1 if ( $schema_type eq "string" || $schema_type eq "number" );  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         elsif ( $given_type eq "integer_or_string" ) {  | 
| 
46
 | 
131
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
1103
 | 
             return 1 if ( $schema_type eq "string" || $schema_type eq "number" || $schema_type eq "integer" );  | 
| 
 
 | 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
48
 | 
184
 | 
 
 | 
 
 | 
 
 | 
 
 | 
571
 | 
         return 0;  | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  |