| 1 | package JSON::Schema::AsType::Draft2019_09::Vocabulary::Validation; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 14 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 14 | $JSON::Schema::AsType::Draft2019_09::Vocabulary::Validation::VERSION = '1.0.0'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Validation vocabulary for draft 2019-09 schemas | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 14 | ▶ | use 5.42.0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 14 | ▶ | use feature qw/ module_true /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 14 | ▶ | use Types::Standard qw/Any/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 14 | ▶ | use List::Util qw/ pairmap /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 14 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 14 | ▶ | use JSON::Schema::AsType::Draft2019_09::Types qw/ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | DependentRequired | ||||||||||||||||||||||||||||||||||||||||||
| 18 | DependentSchemas | ||||||||||||||||||||||||||||||||||||||||||
| 19 | UnevaluatedProperties | ||||||||||||||||||||||||||||||||||||||||||
| 20 | UnevaluatedItems | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 14 | /; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 14 | with 'JSON::Schema::AsType::Draft7::Keywords' => { -exclude => [] }; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | __PACKAGE__->meta->add_method( | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | '_keyword_$recursiveRef' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keyword_$recursiveRef: not called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my ( $self, $ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $schema; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | return Type::Tiny->new( | ||||||||||||||||||||||||||||||||||||||||||
| 32 | name => 'RecursiveRef', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | display_name => "RecursiveRef($ref)", | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 422 | ▶ | constraint => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 422 | my $v = $_; | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 422 | my $anchor; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 422 | my $parent = $self; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 422 | my $first_id; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 422 | ▶ | while ( $parent = $parent->parent_schema ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | # warn "===> ".$parent->uri, "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # warn "anchor: ", $anchor && $anchor->uri, "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # warn "first ", $first_id && $first_id->uri, "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 943 | ▶ | if ( $parent->schema->{'$id'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$parent->schema->{"\$id"} and not $parent->schema->{"\$recursiveAnchor"} and not $first_id
$parent->schema->{"\$id"} and not $parent->schema->{"\$recursiveAnchor"}
MC/DC66%2/3
$parent->schema->{"\$id"} and not $parent->schema->{"\$recursiveAnchor"} and not $first_id
$parent->schema->{"\$id"}
not $parent->schema->{"\$recursiveAnchor"}
not $first_id
Truth table75%3/4
A and not(B) and not(C)
A= $parent->schema->{"\$id"}B= not $parent->schema->{"\$recursiveAnchor"}C= not $first_id
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | and !$parent->schema->{'$recursiveAnchor'} | ||||||||||||||||||||||||||||||||||||||||||
| 50 | and not $first_id ) { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 52 | $first_id = $parent; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 52 | last; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | $anchor = $parent | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 891 | ▶ | if $parent->schema->{'$recursiveAnchor'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | # warn "anchor: ", $anchor && $anchor->uri, "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 59 | # warn "first ", $first_id && $first_id->uri, "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 422 | ▶ | if ( !$anchor ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 52 | ▶ | if ($first_id) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 27 | return $first_id->check($v); | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 25 | my $method = '_keyword_$ref'; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 25 | my $type = $self->$method($ref); | |||||||||||||||||||||||||||||||||||||||||
| 67 | 25 | ▶ | $type = $type->base_type if $type->can('base_type'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 25 | return $type->check($v); | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | # use DDP; p $anchor->schema; | ||||||||||||||||||||||||||||||||||||||||||
| 72 | # warn "checking for $v\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 370 | return $anchor->base_type->check($v); | |||||||||||||||||||||||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 8 | ▶ | sub _keyword_dependentRequired { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keyword_dependentRequired: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 8 | my ( $self, $depends ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 8 | DependentRequired [$depends]; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 12 | ▶ | sub _keyword_dependentSchemas { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keyword_dependentSchemas: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 12 | my ( $self, $depends ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | my %depends = | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 19 | ▶ | pairmap { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 19 | $a => $self->sub_schema( $b, "#./dependentSchema/$a" )->base_type } | |||||||||||||||||||||||||||||||||||||||||
| 91 | 12 | %$depends; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 12 | DependentSchemas [ \%depends ]; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 64 | ▶ | sub _keyword_unevaluatedProperties( $self, $subschema ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keyword_unevaluatedProperties: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 64 | my $schema = $self->sub_schema( $subschema, '#./unevaluatedProperties' ); | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 64 | return UnevaluatedProperties [ $schema->base_type ]; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 31 | ▶ | sub _keyword_unevaluatedItems( $self, $subschema ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keyword_unevaluatedItems: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 31 | my $schema = $self->sub_schema( $subschema, '#./unevaluatedItems' ); | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 31 | return UnevaluatedItems [ $schema->base_type ]; | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | __END__ | ||||||||||||||||||||||||||||||||||||||||||