line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::UniqueItems; |
2
|
|
|
|
|
|
|
|
3
|
47
|
|
|
47
|
|
21499
|
use strict; |
|
47
|
|
|
|
|
60
|
|
|
47
|
|
|
|
|
1117
|
|
4
|
47
|
|
|
47
|
|
153
|
use warnings; |
|
47
|
|
|
|
|
51
|
|
|
47
|
|
|
|
|
1007
|
|
5
|
47
|
|
|
47
|
|
150
|
use parent qw(JSV::Keyword); |
|
47
|
|
|
|
|
49
|
|
|
47
|
|
|
|
|
176
|
|
6
|
|
|
|
|
|
|
|
7
|
47
|
|
|
47
|
|
2033
|
use List::MoreUtils qw(uniq); |
|
47
|
|
|
|
|
58
|
|
|
47
|
|
|
|
|
231
|
|
8
|
|
|
|
|
|
|
|
9
|
47
|
|
|
47
|
|
12827
|
use JSV::Keyword qw(:constants); |
|
47
|
|
|
|
|
60
|
|
|
47
|
|
|
|
|
10195
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub instance_type() { INSTANCE_TYPE_ARRAY(); } |
12
|
|
|
|
|
|
|
sub keyword() { "uniqueItems" } |
13
|
|
|
|
|
|
|
sub keyword_priority() { 10; } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub validate { |
16
|
34
|
|
|
34
|
0
|
32
|
my ($class, $context, $schema, $instance) = @_; |
17
|
|
|
|
|
|
|
|
18
|
34
|
|
|
|
|
79
|
my $keyword_value = $class->keyword_value($schema); |
19
|
|
|
|
|
|
|
|
20
|
34
|
50
|
|
|
|
119
|
if ($keyword_value) { |
21
|
34
|
|
|
|
|
170
|
$context->json->canonical(1); |
22
|
|
|
|
|
|
|
my @unique = uniq map { |
23
|
34
|
|
|
|
|
159
|
$context->json->encode($_) |
|
92
|
|
|
|
|
509
|
|
24
|
|
|
|
|
|
|
} @$instance; |
25
|
|
|
|
|
|
|
|
26
|
34
|
100
|
|
|
|
387
|
if (scalar @unique != scalar @$instance) { |
27
|
16
|
|
|
|
|
36
|
$context->log_error("The instance array is not unique"); |
28
|
|
|
|
|
|
|
} |
29
|
34
|
|
|
|
|
57
|
$context->json->canonical(0); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |