line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
16
|
|
|
16
|
|
2885
|
use warnings; |
|
16
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
446
|
|
4
|
16
|
|
|
16
|
|
78
|
|
|
16
|
|
|
|
|
33
|
|
|
16
|
|
|
|
|
366
|
|
5
|
|
|
|
|
|
|
use Moo; |
6
|
16
|
|
|
16
|
|
74
|
use Carp; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
81
|
|
7
|
16
|
|
|
16
|
|
4497
|
use Module::Load qw(autoload); |
|
16
|
|
|
|
|
33
|
|
|
16
|
|
|
|
|
977
|
|
8
|
16
|
|
|
16
|
|
2588
|
use Types::Standard qw(ConsumerOf ArrayRef HashRef); |
|
16
|
|
|
|
|
5888
|
|
|
16
|
|
|
|
|
96
|
|
9
|
16
|
|
|
16
|
|
884
|
use namespace::clean; |
|
16
|
|
|
|
|
30
|
|
|
16
|
|
|
|
|
112
|
|
10
|
16
|
|
|
16
|
|
12892
|
|
|
16
|
|
|
|
|
38
|
|
|
16
|
|
|
|
|
103
|
|
11
|
|
|
|
|
|
|
has extensions => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
isa => ArrayRef[ConsumerOf['Dancer2::Plugin::FormValidator::Role::Extension']], |
14
|
|
|
|
|
|
|
predicate => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has validators => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => HashRef, |
20
|
|
|
|
|
|
|
lazy => 1, |
21
|
|
|
|
|
|
|
builder => sub { |
22
|
|
|
|
|
|
|
my ($self) = @_; |
23
|
16
|
|
|
16
|
|
215
|
|
24
|
|
|
|
|
|
|
my %plugin_validators; |
25
|
16
|
|
|
|
|
32
|
|
26
|
|
|
|
|
|
|
for my $validator (keys % { $self->_validators }) { |
27
|
16
|
|
|
|
|
28
|
$plugin_validators{$validator} = { |
|
16
|
|
|
|
|
56
|
|
28
|
|
|
|
|
|
|
extension => undef, |
29
|
|
|
|
|
|
|
validator => $self->_validators->{$validator}, |
30
|
256
|
|
|
|
|
446
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
if ($self->has_extensions) { |
34
|
16
|
100
|
|
|
|
118
|
for my $extension (@{ $self->extensions }) { |
35
|
11
|
|
|
|
|
26
|
my %extension_validators; |
|
11
|
|
|
|
|
46
|
|
36
|
2
|
|
|
|
|
5
|
|
37
|
|
|
|
|
|
|
for my $validator (keys %{ $extension->validators } ) { |
38
|
2
|
|
|
|
|
4
|
$extension_validators{$validator} = { |
|
2
|
|
|
|
|
10
|
|
39
|
|
|
|
|
|
|
extension => $extension, |
40
|
|
|
|
|
|
|
validator => $extension->validators->{$validator}, |
41
|
4
|
|
|
|
|
28
|
}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
%plugin_validators = (%plugin_validators, %extension_validators); |
45
|
2
|
|
|
|
|
36
|
}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return \%plugin_validators; |
49
|
16
|
|
|
|
|
322
|
} |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my ($self, $name) = @_; |
53
|
|
|
|
|
|
|
|
54
|
88
|
|
|
88
|
0
|
234
|
if (my $validator_struct = $self->validators->{$name}) { |
55
|
|
|
|
|
|
|
my $extension = $validator_struct->{extension}; |
56
|
88
|
50
|
|
|
|
1638
|
my $class = $validator_struct->{validator}; |
57
|
88
|
|
|
|
|
1064
|
|
58
|
88
|
|
|
|
|
178
|
autoload $class; |
59
|
|
|
|
|
|
|
|
60
|
88
|
|
|
|
|
322
|
my $role = 'Dancer2::Plugin::FormValidator::Role::Validator'; |
61
|
|
|
|
|
|
|
|
62
|
88
|
|
|
|
|
4788
|
my $validator = $extension |
63
|
|
|
|
|
|
|
? $class->new(extension => $extension) |
64
|
88
|
100
|
|
|
|
1157
|
: $class->new; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
if (not $validator->does($role)) { |
67
|
|
|
|
|
|
|
Carp::croak("Validator: $class should implement $role\n"); |
68
|
88
|
50
|
|
|
|
52650
|
} |
69
|
0
|
|
|
|
|
0
|
|
70
|
|
|
|
|
|
|
return $validator; |
71
|
|
|
|
|
|
|
} |
72
|
88
|
|
|
|
|
2632
|
|
73
|
|
|
|
|
|
|
Carp::croak("$name is not defined\n"); |
74
|
|
|
|
|
|
|
} |
75
|
0
|
|
|
|
|
0
|
|
76
|
|
|
|
|
|
|
# Validators map. |
77
|
|
|
|
|
|
|
return { |
78
|
|
|
|
|
|
|
accepted => 'Dancer2::Plugin::FormValidator::Validator::Accepted', |
79
|
|
|
|
|
|
|
alpha => 'Dancer2::Plugin::FormValidator::Validator::Alpha', |
80
|
|
|
|
|
|
|
alpha_num => 'Dancer2::Plugin::FormValidator::Validator::AlphaNum', |
81
|
272
|
|
|
272
|
|
2006
|
boolean => 'Dancer2::Plugin::FormValidator::Validator::Boolean', |
82
|
|
|
|
|
|
|
enum => 'Dancer2::Plugin::FormValidator::Validator::Enum', |
83
|
|
|
|
|
|
|
email => 'Dancer2::Plugin::FormValidator::Validator::Email', |
84
|
|
|
|
|
|
|
email_dns => 'Dancer2::Plugin::FormValidator::Validator::EmailDns', |
85
|
|
|
|
|
|
|
integer => 'Dancer2::Plugin::FormValidator::Validator::Integer', |
86
|
|
|
|
|
|
|
length_max => 'Dancer2::Plugin::FormValidator::Validator::LengthMax', |
87
|
|
|
|
|
|
|
length_min => 'Dancer2::Plugin::FormValidator::Validator::LengthMin', |
88
|
|
|
|
|
|
|
max => 'Dancer2::Plugin::FormValidator::Validator::Max', |
89
|
|
|
|
|
|
|
min => 'Dancer2::Plugin::FormValidator::Validator::Min', |
90
|
|
|
|
|
|
|
numeric => 'Dancer2::Plugin::FormValidator::Validator::Numeric', |
91
|
|
|
|
|
|
|
required => 'Dancer2::Plugin::FormValidator::Validator::Required', |
92
|
|
|
|
|
|
|
required_with => 'Dancer2::Plugin::FormValidator::Validator::RequiredWith', |
93
|
|
|
|
|
|
|
same => 'Dancer2::Plugin::FormValidator::Validator::Same', |
94
|
|
|
|
|
|
|
}; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |