line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::Text; |
2
|
72
|
|
|
72
|
|
2525420
|
use Mojo::Base -strict; |
|
72
|
|
|
|
|
9020
|
|
|
72
|
|
|
|
|
541
|
|
3
|
72
|
|
|
72
|
|
7893
|
use Mojolicious::Plugin::Vparam::Common; |
|
72
|
|
|
|
|
184
|
|
|
72
|
|
|
|
|
25632
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub check_str($) { |
6
|
65
|
100
|
|
65
|
0
|
249
|
return 'Value is not defined' unless defined $_[0]; |
7
|
55
|
|
|
|
|
289
|
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
|
20
|
return 'Value is not defined' unless defined $_[0]; |
16
|
7
|
100
|
|
|
|
37
|
return sprintf 'The length should be greater than %s', $_[1] |
17
|
|
|
|
|
|
|
unless length( $_[0] ) >= $_[1]; |
18
|
|
|
|
|
|
|
|
19
|
5
|
100
|
100
|
|
|
58
|
return 'Value must contain characters and digits' |
20
|
|
|
|
|
|
|
unless $_[0] =~ m{\d} and $_[0] =~ m{\D}; |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
|
|
12
|
return 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub register { |
26
|
74
|
|
|
74
|
0
|
275
|
my ($class, $self, $app, $conf) = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$app->vtype( |
29
|
|
|
|
|
|
|
str => |
30
|
60
|
|
|
60
|
|
245
|
pre => sub{ trim $_[1] }, |
31
|
60
|
|
|
60
|
|
177
|
valid => sub{ check_str $_[1] }, |
32
|
74
|
|
|
|
|
794
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$app->vtype( |
35
|
|
|
|
|
|
|
text => |
36
|
5
|
|
|
5
|
|
25
|
valid => sub{ check_str $_[1] }, |
37
|
74
|
|
|
|
|
749
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$app->vtype( |
40
|
|
|
|
|
|
|
password => |
41
|
7
|
|
|
7
|
|
26
|
valid => sub{ check_password $_[1], $conf->{password_min} }, |
42
|
74
|
|
|
|
|
679
|
); |
43
|
|
|
|
|
|
|
|
44
|
74
|
|
|
|
|
341
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |