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
|
108
|
|
|
108
|
|
67825
|
use strict; |
|
108
|
|
|
|
|
212
|
|
|
108
|
|
|
|
|
2832
|
|
6
|
108
|
|
|
108
|
|
519
|
use warnings; |
|
108
|
|
|
|
|
239
|
|
|
108
|
|
|
|
|
2842
|
|
7
|
|
|
|
|
|
|
|
8
|
108
|
|
|
108
|
|
527
|
use base 'Validation::Class::Directive'; |
|
108
|
|
|
|
|
175
|
|
|
108
|
|
|
|
|
8598
|
|
9
|
|
|
|
|
|
|
|
10
|
108
|
|
|
108
|
|
648
|
use Validation::Class::Util; |
|
108
|
|
|
|
|
222
|
|
|
108
|
|
|
|
|
779
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900057'; # 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
|
15
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
7
|
50
|
33
|
|
|
40
|
if (defined $field->{uuid} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
7
|
50
|
33
|
|
|
36
|
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
|
|
|
|
56
|
$self->error($proto, $field) unless $param =~ $ure; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
7
|
|
|
|
|
24
|
return $self; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |