[Catalyst] Form validation in insert() and update()?
Matt S Trout
dbix-class at trout.me.uk
Tue May 15 22:55:07 GMT 2007
On Tue, May 15, 2007 at 01:04:42PM -0700, mla wrote:
> Okay, thanks very much for this. So in terms of the model constraints,
> you will validate everything twice. Once at the controller layer (where
> it leverages info from the model), and once in the model itself.
>
> So you can interrogate the model to find out, for example, that the
> email column can't be longer than 100 characters and should match the
> pattern /@/ (just to keep it simple here).
>
> Do you expose something like a Model->valid_email() method that can be
> used both within the model and from the controller?
my $tc = Model->meta->get_attribute('email')->type_constraint;
my $error = $tc->validate($value); # undef for 'value ok'
Here lies the joy of Moose everywhere :)
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director Want a managed development or deployment platform?
Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/
More information about the Catalyst
mailing list