line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
37
|
|
|
37
|
|
30793
|
use strict; |
|
37
|
|
|
|
|
81
|
|
|
37
|
|
|
|
|
1727
|
|
3
|
37
|
|
|
37
|
|
292
|
use warnings; |
|
37
|
|
|
|
|
73
|
|
|
37
|
|
|
|
|
14530
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Validator::Declarative::Rules::Converters; |
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
$Validator::Declarative::Rules::Converters::VERSION = '1.20130722.2105'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Declarative parameters validation - default converter rules |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Validator::Declarative; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# INTERNALS |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _assume_true { |
19
|
23
|
|
|
23
|
|
34
|
my ($input) = @_; |
20
|
23
|
100
|
66
|
|
|
165
|
return ( defined($input) && $input =~ /^\s*(0|no|n|false|f|off)\s*$/i ) ? 0 : 1; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _assume_false { |
24
|
23
|
|
|
23
|
|
31
|
my ($input) = @_; |
25
|
23
|
100
|
66
|
|
|
185
|
return ( defined($input) && $input =~ /^\s*(1|yes|y|true|t|on)\s*$/i ) ? 1 : 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _register_default_converters { |
29
|
37
|
|
|
37
|
|
235
|
Validator::Declarative::register_converter( |
30
|
|
|
|
|
|
|
assume_true => \&_assume_true, |
31
|
|
|
|
|
|
|
assume_false => \&_assume_false, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
_register_default_converters(); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; # End of Validator::Declarative::Rules::Converters |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |