[Catalyst] Catalyst::Plugin::FormValidator questions

John Wang johncwang at gmail.com
Tue Nov 15 22:26:49 CET 2005


I got Catalyst::Plugin::FormValidator::Simple working quickly and was able
to get Data::FormValidator to work stand-alone (outside of Cat), however I
am unsuccessful in getting Catalyst::Plugin::FormValidator to work. Some
issues:

(1) How do you check a built-in constraint method? With the following,
required/has_missing works but the built-in email constraint always returns
invalid. What am I missing?

my $profile = {
required => ['field1'],
optional => ['field2'],
constraint_methods => {
field2 => 'email'
}
}
$c->form($profile);

(2) How do you call a custom constraint method in Cat and return a value? I
tried the following unsuccessfully:

sub default : Private {
...
my $profile = {
required => ['field1'],
optional => ['field2'],
constraint_methods => {
field2 => $c->forward('check_field2');
}
}
$c->form($profile);
}

sub check_field2 : Private {
my ($self,$c) = @_;
$c->form->name_this($c->form->get_current_constraint_field);
my $val = $c->form->get_current_constraint_value;
return length($val) > 5 ? 1 : 0; # also tried ? 1 : '';
}

The error was:

Caught exception "No constraint found named '0' at ...

Thanks,
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20051115/d070bbba/attachment.htm


More information about the Catalyst mailing list