line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::Text; |
2
|
72
|
|
|
72
|
|
2288416
|
use Mojo::Base -strict; |
|
72
|
|
|
|
|
7460
|
|
|
72
|
|
|
|
|
456
|
|
3
|
72
|
|
|
72
|
|
6627
|
use Mojolicious::Plugin::Vparam::Common; |
|
72
|
|
|
|
|
136
|
|
|
72
|
|
|
|
|
22527
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub check_str($) { |
6
|
65
|
100
|
|
65
|
0
|
224
|
return 'Value is not defined' unless defined $_[0]; |
7
|
55
|
|
|
|
|
174
|
return 0; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub check_text($) { |
11
|
0
|
|
|
0
|
0
|
0
|
return check_str $_[0]; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub check_password($$) { |
15
|
7
|
50
|
|
7
|
0
|
15
|
return 'Value is not defined' unless defined $_[0]; |
16
|
7
|
100
|
|
|
|
28
|
return sprintf 'The length should be greater than %s', $_[1] |
17
|
|
|
|
|
|
|
unless length( $_[0] ) >= $_[1]; |
18
|
|
|
|
|
|
|
|
19
|
5
|
100
|
100
|
|
|
45
|
return 'Value must contain characters and digits' |
20
|
|
|
|
|
|
|
unless $_[0] =~ m{\d} and $_[0] =~ m{\D}; |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
|
|
10
|
return 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub register { |
26
|
74
|
|
|
74
|
0
|
211
|
my ($class, $self, $app, $conf) = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$app->vtype( |
29
|
|
|
|
|
|
|
str => |
30
|
60
|
|
|
60
|
|
178
|
pre => sub{ trim $_[1] }, |
31
|
60
|
|
|
60
|
|
136
|
valid => sub{ check_str $_[1] }, |
32
|
74
|
|
|
|
|
621
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$app->vtype( |
35
|
|
|
|
|
|
|
text => |
36
|
5
|
|
|
5
|
|
13
|
valid => sub{ check_str $_[1] }, |
37
|
74
|
|
|
|
|
613
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$app->vtype( |
40
|
|
|
|
|
|
|
password => |
41
|
7
|
|
|
7
|
|
16
|
valid => sub{ check_password $_[1], $conf->{password_min} }, |
42
|
74
|
|
|
|
|
542
|
); |
43
|
|
|
|
|
|
|
|
44
|
74
|
|
|
|
|
272
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |