line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Validator::LIVR::Rules::Modifiers; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
15
|
use strict; |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
89
|
|
4
|
4
|
|
|
4
|
|
12
|
use warnings; |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
1415
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.0'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub trim { |
9
|
|
|
|
|
|
|
return sub { |
10
|
5
|
|
|
5
|
|
6
|
my ( $value, undef, $output_ref ) = @_; |
11
|
5
|
100
|
66
|
|
|
25
|
return if !defined($value) || ref($value) || $value eq ''; |
|
|
|
66
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
|
|
6
|
$$output_ref = $value; |
14
|
4
|
|
|
|
|
13
|
$$output_ref =~ s/^\s*//; |
15
|
4
|
|
|
|
|
32
|
$$output_ref =~ s/\s*$//; |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
|
|
9
|
return; |
18
|
3
|
|
|
3
|
0
|
18
|
}; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub to_lc { |
22
|
|
|
|
|
|
|
return sub { |
23
|
9
|
|
|
9
|
|
10
|
my ( $value, undef, $output_ref ) = @_; |
24
|
9
|
100
|
66
|
|
|
41
|
return if !defined($value) || ref($value) || $value eq ''; |
|
|
|
66
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
8
|
|
|
|
|
9
|
$$output_ref = lc($value); |
27
|
8
|
|
|
|
|
11
|
return; |
28
|
10
|
|
|
10
|
0
|
55
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub to_uc { |
32
|
|
|
|
|
|
|
return sub { |
33
|
5
|
|
|
5
|
|
6
|
my ( $value, undef, $output_ref ) = @_; |
34
|
5
|
100
|
66
|
|
|
23
|
return if !defined($value) || ref($value) || $value eq ''; |
|
|
|
66
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
6
|
$$output_ref = uc($value); |
37
|
4
|
|
|
|
|
6
|
return; |
38
|
3
|
|
|
3
|
0
|
17
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub remove { |
42
|
3
|
|
|
3
|
0
|
4
|
my $chars = shift; |
43
|
3
|
|
|
|
|
31
|
my $re = qr/[\Q$chars\E]/; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return sub { |
46
|
5
|
|
|
5
|
|
5
|
my ( $value, undef, $output_ref ) = @_; |
47
|
5
|
100
|
66
|
|
|
27
|
return if !defined($value) || ref($value) || $value eq ''; |
|
|
|
66
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
|
|
16
|
$value =~ s/$re//g; |
50
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
6
|
$$output_ref = $value; |
52
|
4
|
|
|
|
|
7
|
return; |
53
|
3
|
|
|
|
|
22
|
}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub leave_only { |
57
|
3
|
|
|
3
|
0
|
4
|
my $chars = shift; |
58
|
3
|
|
|
|
|
31
|
my $re = qr/[^\Q$chars\E]/; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
return sub { |
61
|
5
|
|
|
5
|
|
5
|
my ( $value, undef, $output_ref ) = @_; |
62
|
5
|
100
|
66
|
|
|
25
|
return if !defined($value) || ref($value) || $value eq ''; |
|
|
|
66
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
4
|
|
|
|
|
23
|
$value =~ s/$re//g; |
65
|
|
|
|
|
|
|
|
66
|
4
|
|
|
|
|
4
|
$$output_ref = $value; |
67
|
4
|
|
|
|
|
6
|
return; |
68
|
3
|
|
|
|
|
23
|
}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub default { |
72
|
8
|
|
|
8
|
0
|
8
|
my $default_value = shift; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
return sub { |
75
|
8
|
|
|
8
|
|
21
|
my ( $value, undef, $output_ref ) = @_; |
76
|
|
|
|
|
|
|
|
77
|
8
|
100
|
100
|
|
|
27
|
if ( !defined($value) || $value eq '' ) { |
78
|
4
|
|
|
|
|
6
|
$$output_ref = $default_value; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
8
|
|
|
|
|
10
|
return; |
82
|
8
|
|
|
|
|
43
|
}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |