JSV/Keyword/Draft4/UniqueItems.pm

filter: Statementstmt 100% 25 / 25 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 94.4% 34 / 36 CC 3 SCAR 5.6
CC
3
Cov
97%
validate
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« JSV/Keyword/Draft4/Not.pm ↑ Summary JSV/Validator.pm »
1 package JSV::Keyword::Draft4::UniqueItems;
2  
3 47 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 47 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 47 ▶use parent qw(JSV::Keyword);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 47 ▶use List::MoreUtils qw(uniq);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 47 ▶use JSV::Keyword qw(:constants);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub instance_type() { INSTANCE_TYPE_ARRAY(); }
12 sub keyword() { "uniqueItems" }
13 sub keyword_priority() { 10; }
14  
15 34 ▶sub validate {
Subroutine validate: called CC=3 SCAR=11.0
Pod undocumented
16 34 my ($class, $context, $schema, $instance) = @_;
17  
18 34 my $keyword_value = $class->keyword_value($schema);
19  
20 34 ▶ if ($keyword_value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keyword_value) 34 0 34
21 34 $context->json->canonical(1);
22 my @unique = uniq map {
23 34 $context->json->encode($_)
24 } @$instance;
25  
26 34 ▶ if (scalar @unique != scalar @$instance) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @unique != scalar @$instance) 16 18 34
27 16 $context->log_error("The instance array is not unique");
28 }
29 34 $context->json->canonical(0);
30 }
31 }
32  
33 47 1;
« JSV/Keyword/Draft4/Not.pm ↑ Summary JSV/Validator.pm »