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
|
|
690
|
use strict; |
|
109
|
|
|
|
|
227
|
|
|
109
|
|
|
|
|
2859
|
|
10
|
109
|
|
|
109
|
|
475
|
use warnings; |
|
109
|
|
|
|
|
197
|
|
|
109
|
|
|
|
|
2633
|
|
11
|
|
|
|
|
|
|
|
12
|
109
|
|
|
109
|
|
556
|
use Validation::Class::Directives; |
|
109
|
|
|
|
|
184
|
|
|
109
|
|
|
|
|
2068
|
|
13
|
109
|
|
|
109
|
|
35842
|
use Validation::Class::Errors; |
|
109
|
|
|
|
|
264
|
|
|
109
|
|
|
|
|
2632
|
|
14
|
|
|
|
|
|
|
|
15
|
109
|
|
|
109
|
|
604
|
use Validation::Class::Util '!has'; |
|
109
|
|
|
|
|
198
|
|
|
109
|
|
|
|
|
398
|
|
16
|
109
|
|
|
109
|
|
594
|
use Carp 'confess'; |
|
109
|
|
|
|
|
236
|
|
|
109
|
|
|
|
|
5593
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '7.900058'; # VERSION |
19
|
|
|
|
|
|
|
|
20
|
109
|
|
|
109
|
|
597
|
use base 'Validation::Class::Mapping'; |
|
109
|
|
|
|
|
241
|
|
|
109
|
|
|
|
|
30204
|
|
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
|
663
|
my $class = shift; |
56
|
|
|
|
|
|
|
|
57
|
355
|
|
|
|
|
1057
|
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
|
|
|
|
1008
|
; |
62
|
|
|
|
|
|
|
|
63
|
355
|
|
|
|
|
768
|
my $self = bless {}, $class; |
64
|
|
|
|
|
|
|
|
65
|
355
|
|
|
|
|
1406
|
$self->add($config); |
66
|
|
|
|
|
|
|
|
67
|
355
|
|
|
|
|
1163
|
return $self; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |