[Catalyst] Catalyst::Plugin::FormValidator questions

John Wang johncwang at gmail.com
Fri Nov 18 10:48:50 CET 2005


On 11/18/05, Jules Bean <jules at jellybean.co.uk> wrote:
>
> sub my_custom_constraint {
> my $c = shift;
> return sub {
> my $dfv = shift;
> my $val = $dfv->get_current_constraint_value;
> my $data = $dfv->get_input_data;
> ...
> ...
> }
> }
>
> should work fine. The anonymous sub should have access to the $c which
> is in the enclosing lexical scope. If I understand DFV correctly (and
> I've only glanced at the manual pages) you'd use that like this:
>
> fieldname => my_custom_constrain($c)


I tried that and couldn't get that to work. My understanding of DFV is that
it doesn't take variable parameters in the profile. The POD example shows
only constants being passed in the profile:

  constraint_methods => {
    email                        => email(),
        prospective_date => coolness(
                min => 40,
                max => 60,
                {fields => [qw/personality smarts good_looks/]}
        ),
  }

http://search.cpan.org/~markstos/Data-FormValidator-4.02/lib/Data/FormValidator/Constraints.pm#New_School_Constraints_Overview

In the example, the variables are all obtained from
$dfv->get_current_constraint_value and $dfv->get_input_data. The profiles
can be stored in external .pl files which may be a reason for this
limitation.

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20051118/0d3d9234/attachment-0001.htm


More information about the Catalyst mailing list