[cgiapp] Data.FormValidator.js - New C::A validation plugin

Lyle webmaster at cosmicperl.com
Mon Jan 26 16:33:03 EST 2009


Joshua Miller wrote:
> Apologies if this has gone too far offtopic...
>   

I'm planning on incorporating this into a new C::A plugin or possibly an 
extension of C::A::VRM, so it's still on topic. Plus me, you and Mark 
are on this list which makes things easier.

> On Mon, Jan 26, 2009 at 6:40 AM, Lyle <webmaster at cosmicperl.com> 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;
>>   }
>>  }
>>
>>     
>
> Currently, there is no easy, built-in way to do this.
>   

I would have thought this was a common enough form requirement that 
potentially a new profile key could be created. Given that this is also 
used for email verification, etc, and not just passwords. After all we 
already have the keys dependency_groups and require_some. Potentially 
all that is needed is an extra feature for dependency_groups?

Assuming that DFV doesn't error on invalid keys (I haven't checked), a 
new key could be made that Data.FormValidator.js uses for this and maybe 
the main DFV will follow later?

> I would like to see Data.FormValidator.js get support for including
> things like that in the profile. While it would break the profiles
> compatibility with Data::FormValidator.pm, a filter could be
> implemented to let the profile be used on both of them. I'm not
> totally sure how that would work out though. At least for myself, I
> usually generate the javascript profile from a profile written in
> perl, and that would make it difficult to include a javascript
> function definition inline.
>   

That's the way I've been testing it out. I think being able to export 
(and thus only having to maintain one) Perl's DFV profile is excellent 
and something that shouldn't be broken. Although it would be very easy 
to add an extra key before it's passed to JS, or remove and extra key 
before sent to DFV.

> I'm open to suggestions and patches, but that conversation should
> probably be moved offlist or to the forum on the Data.FormValidator.js
> berlios page.
>   

See opening sentence :)


Lyle



More information about the cgiapp mailing list