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
|
|
53529
|
use strict; |
|
109
|
|
|
|
|
266
|
|
|
109
|
|
|
|
|
3465
|
|
6
|
109
|
|
|
109
|
|
581
|
use warnings; |
|
109
|
|
|
|
|
286
|
|
|
109
|
|
|
|
|
3109
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
621
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
240
|
|
|
109
|
|
|
|
|
10958
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
834
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
257
|
|
|
109
|
|
|
|
|
645
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900059'; # 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
|
14
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
6
|
|
|
|
|
15
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
6
|
100
|
66
|
|
|
37
|
if (defined $field->{options} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
10
|
my $options = $field->{options}; |
29
|
|
|
|
|
|
|
|
30
|
4
|
50
|
33
|
|
|
16
|
if ( $field->{required} || $param ) { |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my (@options) = isa_arrayref($options) ? |
33
|
4
|
50
|
|
|
|
12
|
@{$options} : split /(?:\s{1,})?[,\-]{1,}(?:\s{1,})?/, $options |
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
21
|
foreach my $option (@options) { |
37
|
8
|
50
|
|
|
|
28
|
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
|
|
|
|
10
|
unless (grep { $param eq $_ } @options) { |
|
8
|
|
|
|
|
25
|
|
46
|
|
|
|
|
|
|
|
47
|
2
|
50
|
|
|
|
20
|
if (my @o = @options) { |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
33
|
|
|
15
|
my$list=(join(' or ',join(', ',@o[0..$#o-1])||(),$o[-1])); |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
15
|
$self->error(@_, $list); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
6
|
|
|
|
|
22
|
return $self; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |