Lyle wrote:
Lyle wrote:
Joshua Miller wrote:
Joshua,
Have you managed to figure out a work around for:-
'constraints' => {
'password1' => {
'constraint' => "check_passwords",
'params' => [ qw( password1 password2 ) ],
},
},
...
sub check_passwords {
my ( $pw1, $pw2 ) = @_;
if ( $pw1 eq $pw2 ) {
return 1;
} else {
return 0;
}
}
I've just tried this code in DFV and I can't get it working? I'm
getting the error
"No constraint found named 'must_match' at
Data/FormValidator/Results.pm line 965."
Can't seem to figure out what I'm missing...
Should be working according to the guide I followed at:-
http://search.cpan.org/~purdy/Data-FormValidator-Tutorial-1.61/lib/Data/FormValidator/Tutorial.pm
Just read
http://search.cpan.org/~markstos/Data-FormValidator-4.63/lib/Data/FormValidator/Constraints.pm#Old_School_Constraints
Seems the example from that tutorial shows a very old way of doing it
(it's been replaced twice!)
Also I kept getting that error until I made it a sub routine reference.
What I got working:-
'constraints' => {
'password1' => {
'constraint_method' => \&must_match,
'params' => [ qw( password1 password2 ) ],
},
},
...
sub must_match {
my ( $dfv, $val1, $val2) = @_;
$dfv->name_this('match');
if ( $val1 eq $val2 ) {
return 1;
}#if
else {
return 0;
}#else
}#sub
Lyle
##### CGI::Application community mailing list ################
## ##
## To unsubscribe, or change your message delivery options, ##
## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ##
## ##
## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ##
## Wiki: http://cgiapp.erlbaum.net/ ##
## ##
################################################################