Hi Mark,
I've tested your solution and it seems to be OK. I hope you will take it
into account on the next release of DFV.
Thank you for your work and patience,
Wojciech Pietron
* Mark Stosberg <[EMAIL PROTECTED]> [2005-05-02 20:10]:
> On 2005-04-28, Wojciech Pietron <[EMAIL PROTECTED]> wrote:
> So I've rewritten the routine slightly differently. However, my personal
> branch of DFV is in a great state of flux now, and I can't properly test
> it without a new branch, which I'm too lazy to create right now.
>
> Here's what I have in mind for a refactor. The key bit is that I skip
> the test for whether or not I have an object, and test directly for the
> presence of a 'param' method.
>
> # Figure out whether the data is a hash reference of a param-capable object
> and return it has a hash
> sub _get_data {
> my ($self,$data) = @_;
> $self->{__INPUT_DATA} = $data;
> require UNIVERSAL;
>
> # This checks whether we have an object that supports param
> if (UNIVERSAL::can($data,'param') ) {
> my %return;
> foreach my $k ($data->param()){
> # we expect param to return an array if there are multiple values
> my @v = $data->param($k);
> $return{$k} = scalar(@v)>1 ? [EMAIL PROTECTED] : $v[0];
> }
> return %return;
> }
> # otherwise, it's already a hash reference
> elsif (ref $data eq 'HASH') {
> return %$data;
> }
> else {
> die "Data::FormValidator->validate() or check() called with invalid
> input data structure.";
> }
> }
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]