line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: UUID Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::UUID; |
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
42177
|
use strict; |
|
109
|
|
|
|
|
249
|
|
|
109
|
|
|
|
|
2630
|
|
6
|
109
|
|
|
109
|
|
471
|
use warnings; |
|
109
|
|
|
|
|
211
|
|
|
109
|
|
|
|
|
2311
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
481
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
191
|
|
|
109
|
|
|
|
|
9331
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
682
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
221
|
|
|
109
|
|
|
|
|
569
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900058'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'mixin' => 1; |
16
|
|
|
|
|
|
|
has 'field' => 1; |
17
|
|
|
|
|
|
|
has 'multi' => 0; |
18
|
|
|
|
|
|
|
has 'message' => '%s is not a valid UUID'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
7
|
|
|
7
|
0
|
16
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
7
|
50
|
33
|
|
|
27
|
if (defined $field->{uuid} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
7
|
50
|
33
|
|
|
26
|
if ($field->{required} || $param) { |
27
|
|
|
|
|
|
|
|
28
|
7
|
|
|
|
|
25
|
my $ure = qr/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i; |
29
|
|
|
|
|
|
|
|
30
|
7
|
100
|
|
|
|
52
|
$self->error($proto, $field) unless $param =~ $ure; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
7
|
|
|
|
|
17
|
return $self; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |