Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Data::FormValidator, equivalent to "require_some_regexp"?

by Herkum (Parson)
on Apr 20, 2007 at 12:37 UTC ( [id://611139]=note: print w/replies, xml ) Need Help??


in reply to Data::FormValidator, equivalent to "require_some_regexp"?

I think the mistake you are making is assuming that the DFV profile has to be hard-coded or that the DFV profile has to do all the work.

Dynamically generate a DFV profile. It is only a hash structure so there is no reason that this will not work.

use CGI; my $q = CGI->new(); my @fields = $q->param(); my @foo_fields; for my $field (@fields) { push @foo_fields, $field if $field qr{^foo_}xm; } my $profile = {}; $profile->{require_some} => { foo_fields => [1, @foo_fields ] };

Replies are listed 'Best First'.
Re^2: Data::FormValidator, equivalent to "require_some_regexp"?
by trammell (Priest) on Apr 20, 2007 at 14:13 UTC
    I think that code can be tightened up a bit:
    $profile->{require_some} = { foo_fields => [ 1, grep /^foo_\d+$/, $q->param ] };
    But apart from that I'm afraid this is the best solution available to me. Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://611139]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2026-04-14 21:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.