line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::Text; |
2
|
73
|
|
|
73
|
|
1177548
|
use Mojo::Base -strict; |
|
73
|
|
|
|
|
115948
|
|
|
73
|
|
|
|
|
426
|
|
3
|
73
|
|
|
73
|
|
7631
|
use Mojolicious::Plugin::Vparam::Common; |
|
73
|
|
|
|
|
137
|
|
|
73
|
|
|
|
|
24077
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub check_str($) { |
6
|
65
|
100
|
|
65
|
0
|
186
|
return 'Value is not defined' unless defined $_[0]; |
7
|
55
|
|
|
|
|
171
|
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
|
24
|
return 'Value is not defined' unless defined $_[0]; |
16
|
7
|
100
|
|
|
|
32
|
return sprintf 'The length should be greater than %s', $_[1] |
17
|
|
|
|
|
|
|
unless length( $_[0] ) >= $_[1]; |
18
|
|
|
|
|
|
|
|
19
|
5
|
100
|
100
|
|
|
39
|
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
|
75
|
|
|
75
|
0
|
224
|
my ($class, $self, $app, $conf) = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$app->vtype( |
29
|
|
|
|
|
|
|
str => |
30
|
60
|
|
|
60
|
|
171
|
pre => sub{ trim $_[1] }, |
31
|
60
|
|
|
60
|
|
138
|
valid => sub{ check_str $_[1] }, |
32
|
75
|
|
|
|
|
683
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$app->vtype( |
35
|
|
|
|
|
|
|
text => |
36
|
5
|
|
|
5
|
|
10
|
valid => sub{ check_str $_[1] }, |
37
|
75
|
|
|
|
|
608
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$app->vtype( |
40
|
|
|
|
|
|
|
password => |
41
|
7
|
|
|
7
|
|
20
|
valid => sub{ check_password $_[1], $conf->{password_min} }, |
42
|
75
|
|
|
|
|
537
|
); |
43
|
|
|
|
|
|
|
|
44
|
75
|
|
|
|
|
274
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |