Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2018-06-23 03:27 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.