On Mon, May 14, 2007 at 04:44:41PM -0500, Dave Rolsky wrote: > 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.
I tend to have much less validation in the "model" (if that's the ORM layer to the database) and instead use the database to enforce the model constraints, where possible. User input (such as a web form) on the other hand, has to have extra validation -- the database can't know the context of the update, of course. That's where the form validation tool comes in for me. It knows how to move the data from the database to an external representation and how to go the other direction, validating along the way. It's a tool the controller can use for populating and updating a web form, for example. > 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? Which is why I like the "form" validation tools to not be specific to the web/HTML side of things. The HTML side of the forms are easy, anyway, and often require hand-customizing. That way the same "forms" can be used for more than just the web environment. -- Bill Moseley [EMAIL PROTECTED] _______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/