On 2004-10-12, Franki <[EMAIL PROTECTED]> wrote:
>
> username =>[
> {
> name => 'user_exists',
> constraint => sub {
> my $username
>= shift;
> foreach
> (@users){return 0 if lc($username) eq $_; }
> return 1;
> },
> params => ['username']
> },
> ],
If you only have one param, the value of the field being validated, you
can omit the 'params' key.
> {
> name => 'confirm',
> constraint => sub {
> my
> $password = shift;
> my
> $password2 = shift;
> return
> ($password eq $password2);
> },
> params => [qw(password password2)]
> },
> ],
Since it's come up several times, I think there ought to be an easier
way to validate confirmatin fields.
I think this the sort of thing that
Data::FormValidator::ConstraintsFactory was developed for (I didn't
write it).
For this example, this almost gets it, when used as a constraint for the
confirmation field:
use Data::FormValidator::ConstraintsFactory qw( :set );
make_cmp_set_constraint( 1, 'eq', $password_1 );
The problem here is how to specify the value of the other field.
($password_1). This could probably be addressed in similar fashion
to how 'params' are passed to constraint. Depending on how they passed
in, they could either name a field value to use, or be a literal value.
Mark
---------------------------------------------------------------------
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]