line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::UUID; |
2
|
73
|
|
|
73
|
|
3604440
|
use Mojo::Base -strict; |
|
73
|
|
|
|
|
111881
|
|
|
73
|
|
|
|
|
413
|
|
3
|
73
|
|
|
73
|
|
7636
|
use Mojolicious::Plugin::Vparam::Common; |
|
73
|
|
|
|
|
151
|
|
|
73
|
|
|
|
|
18513
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub check_uuid($) { |
6
|
6
|
50
|
|
6
|
0
|
18
|
return 'Value is not defined' unless defined $_[0]; |
7
|
6
|
100
|
|
|
|
28
|
return 'Value is not set' unless length $_[0]; |
8
|
5
|
100
|
|
|
|
37
|
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
|
|
|
|
|
14
|
return 0; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub register { |
14
|
75
|
|
|
75
|
0
|
221
|
my ($class, $self, $app, $conf) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$app->vtype( |
17
|
|
|
|
|
|
|
uuid => |
18
|
6
|
|
|
6
|
|
23
|
pre => sub{ trim $_[1] }, |
19
|
6
|
|
|
6
|
|
19
|
valid => sub{ check_uuid $_[1] }, |
20
|
6
|
100
|
|
6
|
|
31
|
post => sub{ defined $_[1] ? lc $_[1] : undef }, |
21
|
75
|
|
|
|
|
1410
|
); |
22
|
|
|
|
|
|
|
|
23
|
75
|
|
|
|
|
315
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |