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
|
|
52231
|
use strict; |
|
109
|
|
|
|
|
264
|
|
|
109
|
|
|
|
|
3168
|
|
6
|
109
|
|
|
109
|
|
567
|
use warnings; |
|
109
|
|
|
|
|
261
|
|
|
109
|
|
|
|
|
2916
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
601
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
273
|
|
|
109
|
|
|
|
|
11221
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
860
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
257
|
|
|
109
|
|
|
|
|
750
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900059'; # 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
|
21
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
7
|
50
|
33
|
|
|
35
|
if (defined $field->{uuid} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
7
|
50
|
33
|
|
|
31
|
if ($field->{required} || $param) { |
27
|
|
|
|
|
|
|
|
28
|
7
|
|
|
|
|
27
|
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
|
|
|
|
64
|
$self->error($proto, $field) unless $param =~ $ure; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
7
|
|
|
|
|
20
|
return $self; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |