line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Params::Profile::Data_FormValidator; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
103
|
|
4
|
3
|
|
|
3
|
|
4152
|
use Data::FormValidator; |
|
3
|
|
|
|
|
133823
|
|
|
3
|
|
|
|
|
994
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = $Params::Profile::VERSION; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Params::Profile::Data_FormValidator - Backend module for Params::Profile |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
See C<Params::Profile> |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
C<Data::FormValidator> methods for C<Params::Profile> |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
### params = HASHREF, profiles = ARRAYREF |
23
|
|
|
|
|
|
|
sub validate { |
24
|
0
|
|
|
0
|
0
|
0
|
my ($self, $params, %profile) = @_; |
25
|
0
|
|
|
|
|
0
|
Data::FormValidator->check($params, \%profile)->is_success; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _merge_profiles { |
29
|
11
|
|
|
11
|
|
19
|
my ($self, @profiles) = @_; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
### Insert first profile in (tobe) merged_profile |
32
|
11
|
|
|
|
|
17
|
my $merged_profile = shift(@profiles); |
33
|
11
|
|
|
|
|
21
|
foreach my $profile (@profiles) { |
34
|
2
|
|
|
|
|
3
|
foreach my $key (keys %{$profile}) { |
|
2
|
|
|
|
|
6
|
|
35
|
4
|
100
|
|
|
|
21
|
if (UNIVERSAL::isa($profile->{$key}, 'ARRAY')) { |
|
|
50
|
|
|
|
|
|
36
|
2
|
|
|
|
|
3
|
push( |
37
|
2
|
|
|
|
|
8
|
@{ $merged_profile->{$key} }, |
38
|
2
|
|
|
|
|
2
|
@{ $profile->{$key} } |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} elsif (UNIVERSAL::isa($profile->{$key}, 'HASH')) { |
41
|
2
|
|
|
|
|
10
|
$merged_profile->{$key}->{$_} = $profile->{$key}->{$_} |
42
|
2
|
|
|
|
|
4
|
for keys( %{ $profile->{$key} }); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
11
|
|
|
|
|
75
|
return $merged_profile; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get_profile { |
51
|
11
|
|
|
11
|
0
|
21
|
my ($self, $params, @profiles) = @_; |
52
|
11
|
|
|
|
|
30
|
return $self->_merge_profiles(@profiles); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub check { |
56
|
6
|
|
|
6
|
0
|
18
|
my ($self, $params, %profile) = @_; |
57
|
6
|
|
|
|
|
33
|
Data::FormValidator->check($params, \%profile); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 AUTHOR |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This module by |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Michiel Ootjers E<lt>michiel@cpan.orgE<gt>. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
and |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Jos Boumans E<lt>kane@cpan.orgE<gt>. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Thanks to Jos Boumans for C<Params::Check>, and the authors of |
77
|
|
|
|
|
|
|
C<Data::FormValidator> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 COPYRIGHT |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This module is |
82
|
|
|
|
|
|
|
copyright (c) 2002 Michiel Ootjers E<lt>michiel@cpan.orgE<gt>. |
83
|
|
|
|
|
|
|
All rights reserved. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This library is free software; |
86
|
|
|
|
|
|
|
you may redistribute and/or modify it under the same |
87
|
|
|
|
|
|
|
terms as Perl itself. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |