[Catalyst] Form validation in insert() and update()?

Dave Rolsky autarch at urth.org
Mon May 14 22:44:41 GMT 2007


On Mon, 14 May 2007, mla wrote:

> Anyone have validation logic in the model and are happy with it?

There are two kinds of validation here. One is model-level validation, and 
yes, it's in my model code. My model throws exceptions, which I trap in 
the controller and "mess with" to make it work for the web UI.

The controller might also do some validation, but all it's doing is 
validating things specific to the controller's environment (in this case, 
the web UI).

Putting your model validation in the controller is a horrible violation of 
the layering that makes MVC work. What do you do when you want to 
insert/update/delete outside of the web UI?

The controller is the bridge between a specific environment (web, CLI, 
REST API) and the model. That means _most_ of your code for an app should 
probably be in the model. The controller is basically a simple translation 
layer between the stuff the client provides and the model API.


-dave

/*===================================================
VegGuide.Org                        www.BookIRead.com
Your guide to all that's veg.       My book blog
===================================================*/



More information about the Catalyst mailing list