|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Valiemon::Attributes::UniqueItems;  | 
| 
2
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
1462
 | 
 use strict;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
71
 | 
    | 
| 
3
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
11
 | 
 use warnings;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
65
 | 
    | 
| 
4
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
13
 | 
 use utf8;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15
 | 
    | 
| 
5
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
67
 | 
 use parent qw(Valiemon::Attributes);  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
19
 | 
    | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
7
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
145
 | 
 use List::MoreUtils qw(any);  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
22
 | 
    | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
9
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
  
0
  
 | 
97
 | 
 sub attr_name { 'uniqueItems' }  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_valid {  | 
| 
12
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
  
0
  
 | 
67
 | 
     my ($class, $context, $schema, $data) = @_;  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
14
 | 
26
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
77
 | 
     return 1 unless ref $data eq 'ARRAY'; # ignore  | 
| 
15
 | 
26
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
106
 | 
     return 1 unless $schema->{uniqueItems}; # skip on false  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $context->in_attr($class, sub {  | 
| 
18
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
 
 | 
48
 | 
         my $unique_data = [];  | 
| 
19
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
         for my $datum (@$data) {  | 
| 
20
 | 
64
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
269
 | 
             return 0 if any { $context->prims->is_equal($_, $datum) } @$unique_data;  | 
| 
 
 | 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
155
 | 
    | 
| 
21
 | 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
220
 | 
             push @$unique_data, $datum;  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
23
 | 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
44
 | 
         return 1;  | 
| 
24
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
332
 | 
     });  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  |