Validator/Constraints/Draft7.pm

filter: Statementstmt 100% 33 / 33 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 93.6% 44 / 47 CC 4 SCAR 7.9
CC
4
Cov
95%
if
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« Validator/Format.pm ↑ Summary Validator/Draft6.pm »
1 package JSONSchema::Validator::Constraints::Draft7;
2  
3 # ABSTRACT: JSON Schema Draft7 specification constraints
4  
5 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 ▶use JSONSchema::Validator::JSONPointer 'json_pointer';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use JSONSchema::Validator::Error 'error';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use JSONSchema::Validator::Util qw(is_type serialize unbool);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 9 ▶use parent 'JSONSchema::Validator::Constraints::Draft6';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 8 ▶sub if {
Subroutine if: called CC=4 SCAR=13.9
Pod undocumented
15 8 my ($self, $instance, $if, $schema, $instance_path, $schema_path, $data) = @_;
16  
17 8 my $errors = $data->{errors};
18 8 $data->{errors} = [];
19  
20 8 my $result = $self->validator->_validate_schema($instance, $if, $instance_path, $schema_path, $data);
21 8 $data->{errors} = $errors;
22 8 ▶ if ($result) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result) 4 4 8
23 4 ▶ return 1 unless exists $schema->{then};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $schema->{"then"} 0 4 4
24 4 my $then = $schema->{then};
25 4 my $spath = json_pointer->append($schema_path, 'then');
26 4 return $self->validator->_validate_schema($instance, $then, $instance_path, $spath, $data);
27 }
28  
29 4 ▶ return 1 unless exists $schema->{else};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $schema->{"else"} 0 4 4
30 4 my $else = $schema->{else};
31 4 my $spath = json_pointer->append($schema_path, 'else');
32 4 return $self->validator->_validate_schema($instance, $else, $instance_path, $spath, $data);
33 }
34  
35 9 1;
36  
37 __END__
« Validator/Format.pm ↑ Summary Validator/Draft6.pm »