line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Alias Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::Alias; |
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
42245
|
use strict; |
|
109
|
|
|
|
|
227
|
|
|
109
|
|
|
|
|
2670
|
|
6
|
109
|
|
|
109
|
|
482
|
use warnings; |
|
109
|
|
|
|
|
204
|
|
|
109
|
|
|
|
|
2476
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
652
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
195
|
|
|
109
|
|
|
|
|
8399
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
673
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
251
|
|
|
109
|
|
|
|
|
571
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900058'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'mixin' => 0; |
16
|
|
|
|
|
|
|
has 'field' => 1; |
17
|
|
|
|
|
|
|
has 'multi' => 0; |
18
|
|
|
|
|
|
|
has 'dependencies' => sub {{ |
19
|
|
|
|
|
|
|
normalization => ['name'], |
20
|
|
|
|
|
|
|
validation => ['name'] |
21
|
|
|
|
|
|
|
}}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub normalize { |
24
|
|
|
|
|
|
|
|
25
|
1009
|
|
|
1009
|
0
|
2183
|
my ($self, $proto, $field, $param) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# create a map from aliases if applicable |
28
|
|
|
|
|
|
|
|
29
|
1009
|
|
|
|
|
3133
|
$self->execute_alias_mapping($proto, $field, $param); |
30
|
|
|
|
|
|
|
|
31
|
1009
|
|
|
|
|
1912
|
return $self; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub before_validation { |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
4
|
0
|
13
|
my ($self, $proto, $field, $param) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# create a map from aliases if applicable |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
14
|
$self->execute_alias_mapping($proto, $field, $param); |
42
|
|
|
|
|
|
|
|
43
|
4
|
|
|
|
|
13
|
return $self; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub execute_alias_mapping { |
48
|
|
|
|
|
|
|
|
49
|
1013
|
|
|
1013
|
0
|
2042
|
my ($self, $proto, $field, $param) = @_; |
50
|
|
|
|
|
|
|
|
51
|
1013
|
100
|
|
|
|
2470
|
if (defined $field->{alias}) { |
52
|
|
|
|
|
|
|
|
53
|
20
|
|
|
|
|
33
|
my $name = $field->{name}; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $aliases = isa_arrayref($field->{alias}) ? |
56
|
20
|
50
|
|
|
|
52
|
$field->{alias} : [$field->{alias}] |
57
|
|
|
|
|
|
|
; |
58
|
|
|
|
|
|
|
|
59
|
20
|
|
|
|
|
34
|
foreach my $alias (@{$aliases}) { |
|
20
|
|
|
|
|
43
|
|
60
|
|
|
|
|
|
|
|
61
|
20
|
100
|
|
|
|
51
|
if ($proto->params->has($alias)) { |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# rename the submitted parameter alias with the field name |
64
|
6
|
|
|
|
|
19
|
$proto->params->add($name => $proto->params->delete($alias)); |
65
|
|
|
|
|
|
|
|
66
|
5
|
|
|
|
|
14
|
push @{$proto->stash->{'validation.fields'}}, $name unless |
67
|
6
|
100
|
|
|
|
13
|
grep { $name eq $_} @{$proto->stash->{'validation.fields'}} |
|
2
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
23
|
|
68
|
|
|
|
|
|
|
; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
1013
|
|
|
|
|
1555
|
return $self; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |