line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::UUID; |
2
|
72
|
|
|
72
|
|
2553192
|
use Mojo::Base -strict; |
|
72
|
|
|
|
|
8658
|
|
|
72
|
|
|
|
|
463
|
|
3
|
72
|
|
|
72
|
|
6733
|
use Mojolicious::Plugin::Vparam::Common; |
|
72
|
|
|
|
|
139
|
|
|
72
|
|
|
|
|
16697
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub check_uuid($) { |
6
|
6
|
50
|
|
6
|
0
|
13
|
return 'Value is not defined' unless defined $_[0]; |
7
|
6
|
100
|
|
|
|
22
|
return 'Value is not set' unless length $_[0]; |
8
|
5
|
100
|
|
|
|
25
|
return 'Wrong format' |
9
|
|
|
|
|
|
|
unless $_[0] =~ m{^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$}i; |
10
|
4
|
|
|
|
|
13
|
return 0; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub register { |
14
|
74
|
|
|
74
|
0
|
226
|
my ($class, $self, $app, $conf) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$app->vtype( |
17
|
|
|
|
|
|
|
uuid => |
18
|
6
|
|
|
6
|
|
16
|
pre => sub{ trim $_[1] }, |
19
|
6
|
|
|
6
|
|
12
|
valid => sub{ check_uuid $_[1] }, |
20
|
6
|
100
|
|
6
|
|
27
|
post => sub{ defined $_[1] ? lc $_[1] : undef }, |
21
|
74
|
|
|
|
|
689
|
); |
22
|
|
|
|
|
|
|
|
23
|
74
|
|
|
|
|
304
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |