| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Interface::Validation Registry of Directives |
|
2
|
|
|
|
|
|
|
package Interface::Validation::Registry; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
26200
|
use Bubblegum; |
|
|
1
|
|
|
|
|
181019
|
|
|
|
1
|
|
|
|
|
7
|
|
|
5
|
1
|
|
|
1
|
|
837619
|
use Function::Parameters; |
|
|
1
|
|
|
|
|
2874
|
|
|
|
1
|
|
|
|
|
8
|
|
|
6
|
1
|
|
|
1
|
|
931
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Interface::Validation::Container; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Bubblegum::Constraints -minimal; |
|
11
|
|
|
|
|
|
|
use Class::Load 'load_class'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.01_01'; # VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my @DIRECTIVES = qw( |
|
16
|
|
|
|
|
|
|
Interface::Validation::Directive::Alias |
|
17
|
|
|
|
|
|
|
Interface::Validation::Directive::Default |
|
18
|
|
|
|
|
|
|
Interface::Validation::Directive::Error |
|
19
|
|
|
|
|
|
|
Interface::Validation::Directive::Filter |
|
20
|
|
|
|
|
|
|
Interface::Validation::Directive::Filter::Alpha |
|
21
|
|
|
|
|
|
|
Interface::Validation::Directive::Filter::AlphaNumeric |
|
22
|
|
|
|
|
|
|
Interface::Validation::Directive::Filter::Autocase |
|
23
|
|
|
|
|
|
|
Interface::Validation::Directive::Filter::Capitalize |
|
24
|
|
|
|
|
|
|
Interface::Validation::Directive::Filter::Lowercase |
|
25
|
|
|
|
|
|
|
Interface::Validation::Directive::Filter::Numeric |
|
26
|
|
|
|
|
|
|
Interface::Validation::Directive::Filter::Strip |
|
27
|
|
|
|
|
|
|
Interface::Validation::Directive::Filter::Titlecase |
|
28
|
|
|
|
|
|
|
Interface::Validation::Directive::Filter::Trim |
|
29
|
|
|
|
|
|
|
Interface::Validation::Directive::Filter::Uppercase |
|
30
|
|
|
|
|
|
|
Interface::Validation::Directive::Filtering |
|
31
|
|
|
|
|
|
|
Interface::Validation::Directive::Label |
|
32
|
|
|
|
|
|
|
Interface::Validation::Directive::Messages |
|
33
|
|
|
|
|
|
|
Interface::Validation::Directive::Mixin |
|
34
|
|
|
|
|
|
|
Interface::Validation::Directive::MixinField |
|
35
|
|
|
|
|
|
|
Interface::Validation::Directive::Name |
|
36
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::Between |
|
37
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::DependsOn |
|
38
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::Length |
|
39
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::Matches |
|
40
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::MaxAlpha |
|
41
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::MaxDigits |
|
42
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::MaxLength |
|
43
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::MaxSum |
|
44
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::MaxSymbols |
|
45
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::MinAlpha |
|
46
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::MinDigits |
|
47
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::MinLength |
|
48
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::MinSum |
|
49
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::MinSymbols |
|
50
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::Multiples |
|
51
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::Options |
|
52
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::Pattern |
|
53
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::Required |
|
54
|
|
|
|
|
|
|
Interface::Validation::Directive::Validator::Validation |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has 'controls' => ( |
|
58
|
|
|
|
|
|
|
is => 'ro', |
|
59
|
|
|
|
|
|
|
isa => 'Interface::Validation::Container', |
|
60
|
|
|
|
|
|
|
required => 1, |
|
61
|
|
|
|
|
|
|
); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has 'filters' => ( |
|
64
|
|
|
|
|
|
|
is => 'ro', |
|
65
|
|
|
|
|
|
|
isa => 'Interface::Validation::Container', |
|
66
|
|
|
|
|
|
|
required => 1 |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has 'validators' => ( |
|
70
|
|
|
|
|
|
|
is => 'ro', |
|
71
|
|
|
|
|
|
|
isa => 'Interface::Validation::Container', |
|
72
|
|
|
|
|
|
|
required => 1 |
|
73
|
|
|
|
|
|
|
); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub BUILDARGS { |
|
76
|
|
|
|
|
|
|
my ($class, %args) = @_; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my %defaults; |
|
79
|
|
|
|
|
|
|
my $namespace = 'Interface::Validation::Directive'; |
|
80
|
|
|
|
|
|
|
my $controls = Interface::Validation::Container->new; |
|
81
|
|
|
|
|
|
|
my $filters = Interface::Validation::Container->new; |
|
82
|
|
|
|
|
|
|
my $validators = Interface::Validation::Container->new; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
for my $module (map load_class($_), @DIRECTIVES) { |
|
85
|
|
|
|
|
|
|
my $type = undef; |
|
86
|
|
|
|
|
|
|
my $base = 'Interface::Validation::DirectiveRole'; |
|
87
|
|
|
|
|
|
|
my $meta = $module->meta; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
next unless my $name = do { |
|
90
|
|
|
|
|
|
|
my ($subspace) = $module |
|
91
|
|
|
|
|
|
|
=~ /^${namespace}::(?:(?:Filter|Validator)::)?(.*)/; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$subspace =~ s/([a-z])([A-Z])/$1_$2/g; |
|
94
|
|
|
|
|
|
|
$subspace =~ s/\W+/-/g; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
lc $subspace; |
|
97
|
|
|
|
|
|
|
}; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$type = $validators if !$type && $meta->does_role("${base}::Validator"); |
|
100
|
|
|
|
|
|
|
$type = $filters if !$type && $meta->does_role("${base}::Filter"); |
|
101
|
|
|
|
|
|
|
$type = $controls if !$type; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$type->set($name => $module); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$defaults{controls} = $controls; |
|
107
|
|
|
|
|
|
|
$defaults{filters} = $filters; |
|
108
|
|
|
|
|
|
|
$defaults{validators} = $validators; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
return {%defaults, %args}; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
method directive { |
|
114
|
|
|
|
|
|
|
my $name = _string shift; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
return $self->controls->get($name) |
|
117
|
|
|
|
|
|
|
|| $self->validators->get($name) |
|
118
|
|
|
|
|
|
|
|| $self->filters->get($name); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |