| 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
| |||||||||||
| 23 | 4 | ▶ | return 1 unless exists $schema->{then}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||