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