[Catalyst] Form validation in insert() and update()?
Peter Karman
peter at peknet.com
Tue May 15 20:55:47 GMT 2007
mla scribbled on 05/15/07 13:42:
> Perrin Harkins wrote:
>
> And where do you handle the validation? Only in the controller or in
> both the model and controller?
>
> Could you give a short example of taking an actual field from the
> request parameters, validating it, and updating a row with it?
>
>
You can see an example of this with Rose::DB::Object,
Rose::HTML::Objects and the db (sqlite in this case) at:
http://search.cpan.org/src/KARMAN/Catalyst-Controller-Rose-0.02/t/examples/CatRose/
Basically, the form object validates and spits back friendly errors
messages to the user. If for some reason the data makes it to the ORM
(RDBO) level, the data is also validated there and 500 error returned to
the user. Finally, the db itself has contraints on it that should
validate in consistent ways with the form and the ORM.
This pattern seems to be similar to what mst, Perrin and Bill are also
describing.
--
Peter Karman . http://peknet.com/ . peter at peknet.com
More information about the Catalyst
mailing list