| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Valiemon::Attributes::UniqueItems; |
|
2
|
2
|
|
|
2
|
|
1071
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
55
|
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
50
|
|
|
4
|
2
|
|
|
2
|
|
7
|
use utf8; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
10
|
|
|
5
|
2
|
|
|
2
|
|
42
|
use parent qw(Valiemon::Attributes); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
101
|
use List::MoreUtils qw(any); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
26
|
|
|
26
|
0
|
43
|
sub attr_name { 'uniqueItems' } |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub is_valid { |
|
12
|
26
|
|
|
26
|
0
|
32
|
my ($class, $context, $schema, $data) = @_; |
|
13
|
|
|
|
|
|
|
|
|
14
|
26
|
50
|
|
|
|
57
|
return 1 unless ref $data eq 'ARRAY'; # ignore |
|
15
|
26
|
50
|
|
|
|
70
|
return 1 unless $schema->{uniqueItems}; # skip on false |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$context->in_attr($class, sub { |
|
18
|
26
|
|
|
26
|
|
27
|
my $unique_data = []; |
|
19
|
26
|
|
|
|
|
35
|
for my $datum (@$data) { |
|
20
|
64
|
100
|
|
|
|
179
|
return 0 if any { $context->prims->is_equal($_, $datum) } @$unique_data; |
|
|
56
|
|
|
|
|
103
|
|
|
21
|
52
|
|
|
|
|
136
|
push @$unique_data, $datum; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
14
|
|
|
|
|
27
|
return 1; |
|
24
|
26
|
|
|
|
|
223
|
}); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |