line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::UniqueItems; |
2
|
|
|
|
|
|
|
|
3
|
44
|
|
|
44
|
|
29650
|
use strict; |
|
44
|
|
|
|
|
96
|
|
|
44
|
|
|
|
|
1026
|
|
4
|
44
|
|
|
44
|
|
208
|
use warnings; |
|
44
|
|
|
|
|
82
|
|
|
44
|
|
|
|
|
1171
|
|
5
|
44
|
|
|
44
|
|
211
|
use parent qw(JSV::Keyword); |
|
44
|
|
|
|
|
81
|
|
|
44
|
|
|
|
|
246
|
|
6
|
|
|
|
|
|
|
|
7
|
44
|
|
|
44
|
|
2235
|
use List::MoreUtils qw(uniq); |
|
44
|
|
|
|
|
92
|
|
|
44
|
|
|
|
|
292
|
|
8
|
|
|
|
|
|
|
|
9
|
44
|
|
|
44
|
|
16263
|
use JSV::Keyword qw(:constants); |
|
44
|
|
|
|
|
87
|
|
|
44
|
|
|
|
|
11117
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub instance_type() { INSTANCE_TYPE_ARRAY(); } |
12
|
|
|
|
|
|
|
sub keyword() { "uniqueItems" } |
13
|
|
|
|
|
|
|
sub keyword_priority() { 10; } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub validate { |
16
|
32
|
|
|
32
|
0
|
61
|
my ($class, $context, $schema, $instance) = @_; |
17
|
|
|
|
|
|
|
|
18
|
32
|
|
|
|
|
140
|
my $keyword_value = $class->keyword_value($schema); |
19
|
|
|
|
|
|
|
|
20
|
32
|
50
|
|
|
|
170
|
if ($keyword_value) { |
21
|
|
|
|
|
|
|
my @unique = uniq map { |
22
|
32
|
|
|
|
|
335
|
$context->json->encode($_) |
|
88
|
|
|
|
|
569
|
|
23
|
|
|
|
|
|
|
} @$instance; |
24
|
|
|
|
|
|
|
|
25
|
32
|
100
|
|
|
|
590
|
if (scalar @unique != scalar @$instance) { |
26
|
14
|
|
|
|
|
45
|
$context->log_error("The instance array is not unique"); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |