Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^3: RFC: Class::CGI

by rhesa (Vicar)
on Apr 08, 2006 at 02:27 UTC ( #542010=note: print w/replies, xml ) Need Help??

in reply to Re^2: RFC: Class::CGI
in thread RFC: Class::CGI

Well, I'm not a veteran DFV user, so I may be stumbling here. But something like this:
use Data::FormValidator; use Data::FormValidator::Constraints::DateTime qw(to_datetime); use CGI; use My::Customer; my $results = Data::FormValidator->check( CGI->new, { constraints => { customer => My::Customer->constraint, date => to_datetime('%D'), } } ); if( $results->success ) { my $date = $results->valid('date'); my $customer = $results->valid('customer'); $date->year; $customer->address->zipcode; }
There's no need to inline the profile like that, of course.

&My::Customer::constraint might look like this:

package My::Customer; use base 'My::Class::DBI'; sub constraint { my $pkg = shift; return sub { my $value = shift; return unless $value =~ /^(\d+)$/; return $pkg->retrieve($value); }; }
But, that's all just guesswork on my part (and completely untested). It does show tremendous potential, that I really should try to incorporate in my own work ;)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2016-10-25 22:32 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (330 votes). Check out past polls.