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
|
108
|
|
|
108
|
|
69613
|
use strict; |
|
108
|
|
|
|
|
227
|
|
|
108
|
|
|
|
|
2803
|
|
6
|
108
|
|
|
108
|
|
544
|
use warnings; |
|
108
|
|
|
|
|
208
|
|
|
108
|
|
|
|
|
2830
|
|
7
|
|
|
|
|
|
|
|
8
|
108
|
|
|
108
|
|
571
|
use base 'Validation::Class::Directive'; |
|
108
|
|
|
|
|
238
|
|
|
108
|
|
|
|
|
7525
|
|
9
|
|
|
|
|
|
|
|
10
|
108
|
|
|
108
|
|
660
|
use Validation::Class::Util; |
|
108
|
|
|
|
|
217
|
|
|
108
|
|
|
|
|
721
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900057'; # 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
|
1002
|
|
|
1002
|
0
|
1863
|
my ($self, $proto, $field, $param) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# create a map from aliases if applicable |
28
|
|
|
|
|
|
|
|
29
|
1002
|
|
|
|
|
2841
|
$self->execute_alias_mapping($proto, $field, $param); |
30
|
|
|
|
|
|
|
|
31
|
1002
|
|
|
|
|
2748
|
return $self; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub before_validation { |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
4
|
0
|
11
|
my ($self, $proto, $field, $param) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# create a map from aliases if applicable |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
15
|
$self->execute_alias_mapping($proto, $field, $param); |
42
|
|
|
|
|
|
|
|
43
|
4
|
|
|
|
|
12
|
return $self; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub execute_alias_mapping { |
48
|
|
|
|
|
|
|
|
49
|
1006
|
|
|
1006
|
0
|
1705
|
my ($self, $proto, $field, $param) = @_; |
50
|
|
|
|
|
|
|
|
51
|
1006
|
100
|
|
|
|
2764
|
if (defined $field->{alias}) { |
52
|
|
|
|
|
|
|
|
53
|
20
|
|
|
|
|
38
|
my $name = $field->{name}; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $aliases = isa_arrayref($field->{alias}) ? |
56
|
20
|
50
|
|
|
|
72
|
$field->{alias} : [$field->{alias}] |
57
|
|
|
|
|
|
|
; |
58
|
|
|
|
|
|
|
|
59
|
20
|
|
|
|
|
35
|
foreach my $alias (@{$aliases}) { |
|
20
|
|
|
|
|
67
|
|
60
|
|
|
|
|
|
|
|
61
|
20
|
100
|
|
|
|
109
|
if ($proto->params->has($alias)) { |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# rename the submitted parameter alias with the field name |
64
|
6
|
|
|
|
|
24
|
$proto->params->add($name => $proto->params->delete($alias)); |
65
|
|
|
|
|
|
|
|
66
|
5
|
|
|
|
|
18
|
push @{$proto->stash->{'validation.fields'}}, $name unless |
67
|
6
|
100
|
|
|
|
15
|
grep { $name eq $_} @{$proto->stash->{'validation.fields'}} |
|
2
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
28
|
|
68
|
|
|
|
|
|
|
; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
1006
|
|
|
|
|
1659
|
return $self; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |