line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Options Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::Options; |
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
43151
|
use strict; |
|
109
|
|
|
|
|
292
|
|
|
109
|
|
|
|
|
2624
|
|
6
|
109
|
|
|
109
|
|
480
|
use warnings; |
|
109
|
|
|
|
|
215
|
|
|
109
|
|
|
|
|
2365
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
792
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
202
|
|
|
109
|
|
|
|
|
9245
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
661
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
219
|
|
|
109
|
|
|
|
|
581
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900058'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'mixin' => 1; |
16
|
|
|
|
|
|
|
has 'field' => 1; |
17
|
|
|
|
|
|
|
has 'multi' => 0; |
18
|
|
|
|
|
|
|
has 'message' => '%s must be either %s'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
6
|
|
|
6
|
0
|
12
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
6
|
|
|
|
|
12
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
6
|
100
|
66
|
|
|
29
|
if (defined $field->{options} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
8
|
my $options = $field->{options}; |
29
|
|
|
|
|
|
|
|
30
|
4
|
50
|
33
|
|
|
24
|
if ( $field->{required} || $param ) { |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my (@options) = isa_arrayref($options) ? |
33
|
4
|
50
|
|
|
|
10
|
@{$options} : split /(?:\s{1,})?[,\-]{1,}(?:\s{1,})?/, $options |
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
9
|
foreach my $option (@options) { |
37
|
8
|
50
|
|
|
|
21
|
if ($option =~ /^([^\|]+)\|(.*)/) { |
|
|
50
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
$option = $0; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
elsif (isa_arrayref($option)) { |
41
|
0
|
|
|
|
|
0
|
$option = $option->[0]; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
4
|
100
|
|
|
|
17
|
unless (grep { $param eq $_ } @options) { |
|
8
|
|
|
|
|
23
|
|
46
|
|
|
|
|
|
|
|
47
|
2
|
50
|
|
|
|
9
|
if (my @o = @options) { |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
33
|
|
|
11
|
my$list=(join(' or ',join(', ',@o[0..$#o-1])||(),$o[-1])); |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
10
|
$self->error(@_, $list); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
6
|
|
|
|
|
18
|
return $self; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |