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
|
109
|
|
|
109
|
|
794
|
use strict; |
|
109
|
|
|
|
|
238
|
|
|
109
|
|
|
|
|
3376
|
|
10
|
109
|
|
|
109
|
|
592
|
use warnings; |
|
109
|
|
|
|
|
244
|
|
|
109
|
|
|
|
|
2837
|
|
11
|
|
|
|
|
|
|
|
12
|
109
|
|
|
109
|
|
667
|
use Validation::Class::Directives; |
|
109
|
|
|
|
|
215
|
|
|
109
|
|
|
|
|
2301
|
|
13
|
109
|
|
|
109
|
|
45341
|
use Validation::Class::Errors; |
|
109
|
|
|
|
|
321
|
|
|
109
|
|
|
|
|
3258
|
|
14
|
|
|
|
|
|
|
|
15
|
109
|
|
|
109
|
|
723
|
use Validation::Class::Util '!has'; |
|
109
|
|
|
|
|
249
|
|
|
109
|
|
|
|
|
515
|
|
16
|
109
|
|
|
109
|
|
692
|
use Carp 'confess'; |
|
109
|
|
|
|
|
277
|
|
|
109
|
|
|
|
|
6484
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '7.900059'; # VERSION |
19
|
|
|
|
|
|
|
|
20
|
109
|
|
|
109
|
|
764
|
use base 'Validation::Class::Mapping'; |
|
109
|
|
|
|
|
298
|
|
|
109
|
|
|
|
|
38192
|
|
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
|
355
|
|
|
355
|
1
|
851
|
my $class = shift; |
56
|
|
|
|
|
|
|
|
57
|
355
|
|
|
|
|
1265
|
my $config = $class->build_args(@_); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
confess "Cannot create a new field object without a name attribute" |
60
|
|
|
|
|
|
|
unless $config->{name} |
61
|
355
|
50
|
|
|
|
1330
|
; |
62
|
|
|
|
|
|
|
|
63
|
355
|
|
|
|
|
912
|
my $self = bless {}, $class; |
64
|
|
|
|
|
|
|
|
65
|
355
|
|
|
|
|
1649
|
$self->add($config); |
66
|
|
|
|
|
|
|
|
67
|
355
|
|
|
|
|
1421
|
return $self; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |