line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Container Class for Validation::Class::Field Objects |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Validation::Class::Fields is a container class for L |
4
|
|
|
|
|
|
|
# objects and is derived from the L class. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Validation::Class::Fields; |
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
771
|
use strict; |
|
109
|
|
|
|
|
271
|
|
|
109
|
|
|
|
|
3260
|
|
9
|
109
|
|
|
109
|
|
605
|
use warnings; |
|
109
|
|
|
|
|
240
|
|
|
109
|
|
|
|
|
3113
|
|
10
|
|
|
|
|
|
|
|
11
|
109
|
|
|
109
|
|
609
|
use Validation::Class::Util '!has'; |
|
109
|
|
|
|
|
252
|
|
|
109
|
|
|
|
|
704
|
|
12
|
109
|
|
|
109
|
|
55579
|
use Hash::Flatten (); |
|
109
|
|
|
|
|
520261
|
|
|
109
|
|
|
|
|
2744
|
|
13
|
109
|
|
|
109
|
|
805
|
use Carp; |
|
109
|
|
|
|
|
261
|
|
|
109
|
|
|
|
|
7785
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '7.900059'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
109
|
|
|
109
|
|
753
|
use base 'Validation::Class::Mapping'; |
|
109
|
|
|
|
|
279
|
|
|
109
|
|
|
|
|
11456
|
|
18
|
|
|
|
|
|
|
|
19
|
109
|
|
|
109
|
|
810
|
use Validation::Class::Mapping; |
|
109
|
|
|
|
|
318
|
|
|
109
|
|
|
|
|
2282
|
|
20
|
109
|
|
|
109
|
|
46600
|
use Validation::Class::Field; |
|
109
|
|
|
|
|
399
|
|
|
109
|
|
|
|
|
45257
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub add { |
23
|
|
|
|
|
|
|
|
24
|
825
|
|
|
825
|
1
|
10962
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
825
|
|
|
|
|
2335
|
my $arguments = $self->build_args(@_); |
27
|
825
|
|
|
|
|
1646
|
my @suspects = sort keys %{$arguments}; |
|
825
|
|
|
|
|
3000
|
|
28
|
|
|
|
|
|
|
|
29
|
825
|
50
|
|
|
|
4509
|
confess |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
"Illegal field names detected, possible attempt to define validation " . |
32
|
|
|
|
|
|
|
"rules for a parameter containing an array of nested structures on " . |
33
|
|
|
|
|
|
|
"the following fields: " . join ", ", @suspects |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
if grep /(:.*:|:\d+.)/, @suspects |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
; |
38
|
|
|
|
|
|
|
|
39
|
825
|
|
|
|
|
1583
|
while (my ($key, $value) = each %{$arguments}) { |
|
1377
|
|
|
|
|
4162
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# never overwrite |
42
|
552
|
100
|
|
|
|
1723
|
unless (defined $self->{$key}) { |
43
|
546
|
100
|
|
|
|
1661
|
if (isa_hashref($value)) { |
44
|
233
|
|
|
|
|
641
|
$value->{name} = $key; |
45
|
|
|
|
|
|
|
} |
46
|
546
|
|
|
|
|
1271
|
$self->{$key} = $value; # accept an object as a value |
47
|
|
|
|
|
|
|
$self->{$key} = Validation::Class::Field->new($value) unless |
48
|
546
|
100
|
|
|
|
2651
|
"Validation::Class::Field" eq ref $self->{$key}; # unless obj |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
825
|
|
|
|
|
2451
|
return $self; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub AUTOLOAD { |
58
|
|
|
|
|
|
|
|
59
|
8
|
|
|
8
|
|
59
|
(my $routine = $Validation::Class::Fields::AUTOLOAD) =~ s/.*:://; |
60
|
|
|
|
|
|
|
|
61
|
8
|
|
|
|
|
22
|
my ($self) = @_; |
62
|
|
|
|
|
|
|
|
63
|
8
|
50
|
|
|
|
20
|
if ($routine) { |
64
|
|
|
|
|
|
|
|
65
|
8
|
100
|
|
|
|
26
|
if ($self->has($routine)) { |
66
|
7
|
|
|
|
|
26
|
return $self->get($routine); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
0
|
|
|
219
|
croak sprintf q(Can't locate object method "%s" via package "%s"), |
72
|
|
|
|
|
|
|
$routine, ((ref $_[0] || $_[0]) || 'main') |
73
|
|
|
|
|
|
|
; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
0
|
|
|
sub DESTROY {} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |