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
|
108
|
|
|
108
|
|
66550
|
use strict; |
|
108
|
|
|
|
|
229
|
|
|
108
|
|
|
|
|
2885
|
|
6
|
108
|
|
|
108
|
|
558
|
use warnings; |
|
108
|
|
|
|
|
284
|
|
|
108
|
|
|
|
|
2790
|
|
7
|
|
|
|
|
|
|
|
8
|
108
|
|
|
108
|
|
571
|
use base 'Validation::Class::Directive'; |
|
108
|
|
|
|
|
199
|
|
|
108
|
|
|
|
|
7644
|
|
9
|
|
|
|
|
|
|
|
10
|
108
|
|
|
108
|
|
587
|
use Validation::Class::Util; |
|
108
|
|
|
|
|
225
|
|
|
108
|
|
|
|
|
729
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900057'; # 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
|
16
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
6
|
|
|
|
|
13
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
6
|
100
|
66
|
|
|
41
|
if (defined $field->{options} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
7
|
my $options = $field->{options}; |
29
|
|
|
|
|
|
|
|
30
|
4
|
50
|
33
|
|
|
22
|
if ( $field->{required} || $param ) { |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my (@options) = isa_arrayref($options) ? |
33
|
4
|
50
|
|
|
|
16
|
@{$options} : split /(?:\s{1,})?[,\-]{1,}(?:\s{1,})?/, $options |
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
9
|
foreach my $option (@options) { |
37
|
8
|
50
|
|
|
|
34
|
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
|
|
|
|
8
|
unless (grep { $param eq $_ } @options) { |
|
8
|
|
|
|
|
26
|
|
46
|
|
|
|
|
|
|
|
47
|
2
|
50
|
|
|
|
9
|
if (my @o = @options) { |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
33
|
|
|
16
|
my$list=(join(' or ',join(', ',@o[0..$#o-1])||(),$o[-1])); |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
14
|
$self->error(@_, $list); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
6
|
|
|
|
|
19
|
return $self; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |