Thanks for all the kind advice guys..

I settled on a combination, I have to show some other people how to do this, so I didn't want them to have to create extra named subs for each runmode profile, so I put it all in the one. (from the look of it though, I might end up rethinking that.)

Here is where I am at now.. @users is an array of the users from the DB, and @muncip is an array of the muncipality names..
It seems to work great, but yeesh thats allot of code for form validation. (and I've not even covered the other fields yet.)


Thanks again for the advice.

regards

Frank

my ($results,$err_page) = $self->check_rm('start_window', {
# Required is where you list all form elements that are manditory.
required => [qw/
username
password
password2
muncipality_name
muncipality_number
muncipality_street
muncipality_city
muncipality_state
muncipality_zip
muncipality_auth_officer
muncipality_phone
/],
# List optional form elements here.
optional => [qw/
muncipality_fax
muncipality_email
/],
constraints => {
username =>[
{
name => 'user_exists',
constraint => sub {
my $username = shift;
foreach (@users){return 0 if lc($username) eq $_; }
return 1;
},
params => ['username']
},
],


muncipality_name =>[
{
name => 'muncipality_exists',
constraint => sub {
my $muncipality = shift;
foreach (@muncip){return 0 if lc($muncipality) eq $_; }
return 1;
},
params => ['muncipality_name']
},
],


password =>[
{
name => 'invalid_password1',
constraint => sub {
my $password = shift;
return 0 unless (length($password) >= 6);
return 1;
},
params => ['password']
},
{
name => 'confirm',
constraint => sub {
my $password = shift;
my $password2 = shift;
return ($password eq $password2);
},
params => [qw(password password2)]
},
],



},
filters => ['trim'],
msgs =>
{
any_errors => 'err__',
prefix => 'err_',
constraints => {
'user_exists' => 'User already exists.',
'confirm' => 'Passwords don\'t match.',
'muncipality_exists' => 'muncipality name already exists.',


'invalid_password1' => 'Password must be over 6 characters.',
},
}
});


    return $err_page if $err_page;

---------------------------------------------------------------------
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]



Reply via email to