| 1 | package Params::Profile::Data_FormValidator; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 3 | ▶ | use Data::FormValidator; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 3 | 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 | ▶ | my ($self, $params, %profile) = @_; | ||||||||||||
|
Subroutine
validate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 25 | 0 | Data::FormValidator->check($params, \%profile)->is_success; | |||||||||||||
| 26 | } | ||||||||||||||
| 27 | |||||||||||||||
| 28 | sub _merge_profiles { | ||||||||||||||
| 29 | 11 | ▶ | my ($self, @profiles) = @_; | ||||||||||||
|
Subroutine
_merge_profiles: called CC=6 SCAR=17.9
| |||||||||||||||
| 30 | |||||||||||||||
| 31 | ### Insert first profile in (tobe) merged_profile | ||||||||||||||
| 32 | 11 | my $merged_profile = shift(@profiles); | |||||||||||||
| 33 | 11 | foreach my $profile (@profiles) { | |||||||||||||
| 34 | 2 | foreach my $key (keys %{$profile}) { | |||||||||||||
| 35 | 4 | ▶ | if (UNIVERSAL::isa($profile->{$key}, 'ARRAY')) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 36 | push( | ||||||||||||||
| 37 | 2 | @{ $merged_profile->{$key} }, | |||||||||||||
| 38 | 2 | @{ $profile->{$key} } | |||||||||||||
| 39 | ); | ||||||||||||||
| 40 | } elsif (UNIVERSAL::isa($profile->{$key}, 'HASH')) { | ||||||||||||||
| 41 | $merged_profile->{$key}->{$_} = $profile->{$key}->{$_} | ||||||||||||||
| 42 | 2 | for keys( %{ $profile->{$key} }); | |||||||||||||
| 43 | } | ||||||||||||||
| 44 | } | ||||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | 11 | return $merged_profile; | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | |||||||||||||||
| 50 | sub get_profile { | ||||||||||||||
| 51 | 11 | ▶ | my ($self, $params, @profiles) = @_; | ||||||||||||
|
Subroutine
get_profile: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 52 | 11 | return $self->_merge_profiles(@profiles); | |||||||||||||
| 53 | } | ||||||||||||||
| 54 | |||||||||||||||
| 55 | sub check { | ||||||||||||||
| 56 | 6 | ▶ | my ($self, $params, %profile) = @_; | ||||||||||||
|
Subroutine
check: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 57 | 6 | Data::FormValidator->check($params, \%profile); | |||||||||||||
| 58 | } | ||||||||||||||
| 59 | |||||||||||||||
| 60 | 3 | 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 | ||||||||||||||