line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::UniqueItems; |
2
|
|
|
|
|
|
|
|
3
|
47
|
|
|
47
|
|
35358
|
use strict; |
|
47
|
|
|
|
|
105
|
|
|
47
|
|
|
|
|
1256
|
|
4
|
47
|
|
|
47
|
|
252
|
use warnings; |
|
47
|
|
|
|
|
100
|
|
|
47
|
|
|
|
|
1285
|
|
5
|
47
|
|
|
47
|
|
260
|
use parent qw(JSV::Keyword); |
|
47
|
|
|
|
|
94
|
|
|
47
|
|
|
|
|
275
|
|
6
|
|
|
|
|
|
|
|
7
|
47
|
|
|
47
|
|
2631
|
use List::MoreUtils qw(uniq); |
|
47
|
|
|
|
|
102
|
|
|
47
|
|
|
|
|
334
|
|
8
|
|
|
|
|
|
|
|
9
|
47
|
|
|
47
|
|
19563
|
use JSV::Keyword qw(:constants); |
|
47
|
|
|
|
|
99
|
|
|
47
|
|
|
|
|
14688
|
|
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
|
71
|
my ($class, $context, $schema, $instance) = @_; |
17
|
|
|
|
|
|
|
|
18
|
34
|
|
|
|
|
144
|
my $keyword_value = $class->keyword_value($schema); |
19
|
|
|
|
|
|
|
|
20
|
34
|
50
|
|
|
|
211
|
if ($keyword_value) { |
21
|
34
|
|
|
|
|
313
|
$context->json->canonical(1); |
22
|
|
|
|
|
|
|
my @unique = uniq map { |
23
|
34
|
|
|
|
|
286
|
$context->json->encode($_) |
|
92
|
|
|
|
|
944
|
|
24
|
|
|
|
|
|
|
} @$instance; |
25
|
|
|
|
|
|
|
|
26
|
34
|
100
|
|
|
|
708
|
if (scalar @unique != scalar @$instance) { |
27
|
16
|
|
|
|
|
67
|
$context->log_error("The instance array is not unique"); |
28
|
|
|
|
|
|
|
} |
29
|
34
|
|
|
|
|
115
|
$context->json->canonical(0); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |