line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::UUID; |
2
|
72
|
|
|
72
|
|
2848438
|
use Mojo::Base -strict; |
|
72
|
|
|
|
|
11475
|
|
|
72
|
|
|
|
|
531
|
|
3
|
72
|
|
|
72
|
|
7797
|
use Mojolicious::Plugin::Vparam::Common; |
|
72
|
|
|
|
|
172
|
|
|
72
|
|
|
|
|
19366
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub check_uuid($) { |
6
|
6
|
50
|
|
6
|
0
|
14
|
return 'Value is not defined' unless defined $_[0]; |
7
|
6
|
100
|
|
|
|
21
|
return 'Value is not set' unless length $_[0]; |
8
|
5
|
100
|
|
|
|
30
|
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
|
|
|
|
|
16
|
return 0; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub register { |
14
|
74
|
|
|
74
|
0
|
259
|
my ($class, $self, $app, $conf) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$app->vtype( |
17
|
|
|
|
|
|
|
uuid => |
18
|
6
|
|
|
6
|
|
18
|
pre => sub{ trim $_[1] }, |
19
|
6
|
|
|
6
|
|
15
|
valid => sub{ check_uuid $_[1] }, |
20
|
6
|
100
|
|
6
|
|
32
|
post => sub{ defined $_[1] ? lc $_[1] : undef }, |
21
|
74
|
|
|
|
|
833
|
); |
22
|
|
|
|
|
|
|
|
23
|
74
|
|
|
|
|
378
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |