File Coverage

lib/Params/Profile/Data_FormValidator.pm
Criterion Covered Total %
statement 22 24 91.6
branch 3 4 75.0
condition n/a
subroutine 5 6 83.3
pod 0 3 0.0
total 30 37 81.0


line stmt bran cond sub pod time code
1             package Params::Profile::Data_FormValidator;
2              
3 3     3   10 use strict;
  3         2  
  3         69  
4 3     3   1548 use Data::FormValidator;
  3         55070  
  3         647  
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
15              
16             =head1 DESCRIPTION
17              
18             C methods for C
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   12 my ($self, @profiles) = @_;
30              
31             ### Insert first profile in (tobe) merged_profile
32 11         8 my $merged_profile = shift(@profiles);
33 11         13 foreach my $profile (@profiles) {
34 2         3 foreach my $key (keys %{$profile}) {
  2         4  
35 4 100       17 if (UNIVERSAL::isa($profile->{$key}, 'ARRAY')) {
    50          
36             push(
37 2         3 @{ $merged_profile->{$key} },
38 2         1 @{ $profile->{$key} }
  2         5  
39             );
40             } elsif (UNIVERSAL::isa($profile->{$key}, 'HASH')) {
41             $merged_profile->{$key}->{$_} = $profile->{$key}->{$_}
42 2         2 for keys( %{ $profile->{$key} });
  2         7  
43             }
44             }
45             }
46              
47 11         47 return $merged_profile;
48             }
49              
50             sub get_profile {
51 11     11 0 16 my ($self, $params, @profiles) = @_;
52 11         19 return $self->_merge_profiles(@profiles);
53             }
54              
55             sub check {
56 6     6 0 12 my ($self, $params, %profile) = @_;
57 6         21 Data::FormValidator->check($params, \%profile);
58             }
59              
60             1;
61              
62             __END__