line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Field Object for Validation::Class Classes |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Validation::Class::Field provides functions for processing for field objects |
4
|
|
|
|
|
|
|
# and provides accessors for field directives. This class is derived from the |
5
|
|
|
|
|
|
|
# L class. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Validation::Class::Field; |
8
|
|
|
|
|
|
|
|
9
|
108
|
|
|
108
|
|
536
|
use strict; |
|
108
|
|
|
|
|
202
|
|
|
108
|
|
|
|
|
2789
|
|
10
|
108
|
|
|
108
|
|
521
|
use warnings; |
|
108
|
|
|
|
|
204
|
|
|
108
|
|
|
|
|
2912
|
|
11
|
|
|
|
|
|
|
|
12
|
108
|
|
|
108
|
|
559
|
use Validation::Class::Directives; |
|
108
|
|
|
|
|
196
|
|
|
108
|
|
|
|
|
2287
|
|
13
|
108
|
|
|
108
|
|
55198
|
use Validation::Class::Errors; |
|
108
|
|
|
|
|
283
|
|
|
108
|
|
|
|
|
2775
|
|
14
|
|
|
|
|
|
|
|
15
|
108
|
|
|
108
|
|
598
|
use Validation::Class::Util '!has'; |
|
108
|
|
|
|
|
217
|
|
|
108
|
|
|
|
|
496
|
|
16
|
108
|
|
|
108
|
|
537
|
use Carp 'confess'; |
|
108
|
|
|
|
|
212
|
|
|
108
|
|
|
|
|
6164
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '7.900057'; # VERSION |
19
|
|
|
|
|
|
|
|
20
|
108
|
|
|
108
|
|
539
|
use base 'Validation::Class::Mapping'; |
|
108
|
|
|
|
|
180
|
|
|
108
|
|
|
|
|
32058
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $directives = Validation::Class::Directives->new; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
foreach my $directive ($directives->values) { |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# create accessors from default configuration (once) |
27
|
|
|
|
|
|
|
# ugly hack but it works so it stay .. for now |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
if ($directive->field) { |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $name = $directive->name; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
next if __PACKAGE__->can($name); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# errors object |
36
|
|
|
|
|
|
|
if ($name eq 'errors') { |
37
|
|
|
|
|
|
|
my %spec = |
38
|
|
|
|
|
|
|
($name => sub { Validation::Class::Errors->new }); |
39
|
|
|
|
|
|
|
Validation::Class::Util::has(%spec); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# everything else |
43
|
|
|
|
|
|
|
else { |
44
|
|
|
|
|
|
|
my %spec = |
45
|
|
|
|
|
|
|
($name => sub { undef }); |
46
|
|
|
|
|
|
|
Validation::Class::Util::has(%spec); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub new { |
54
|
|
|
|
|
|
|
|
55
|
354
|
|
|
354
|
1
|
590
|
my $class = shift; |
56
|
|
|
|
|
|
|
|
57
|
354
|
|
|
|
|
1320
|
my $config = $class->build_args(@_); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
confess "Cannot create a new field object without a name attribute" |
60
|
|
|
|
|
|
|
unless $config->{name} |
61
|
354
|
50
|
|
|
|
1260
|
; |
62
|
|
|
|
|
|
|
|
63
|
354
|
|
|
|
|
774
|
my $self = bless {}, $class; |
64
|
|
|
|
|
|
|
|
65
|
354
|
|
|
|
|
1537
|
$self->add($config); |
66
|
|
|
|
|
|
|
|
67
|
354
|
|
|
|
|
1519
|
return $self; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |