On Wed, 2005-01-12 at 17:14 -0500, Vsevolod (Simon) Ilyushchenko wrote:
> I was just wondering if anyone has created some kind of formal pattern
> to deal with this. On a page that has several controllers, this can get
> messy - you have to send data from the model (and maybe from the web) to
> the controller, invoke the error checking function and then transfer
> possibly modified data back to the model.
It seems like the gist of your question is where to do the input
validation. The logical place to do it is in the model objects, but
this can be a pain unless you design them for it. Figuring out exactly
when the object is ready for the data to be validated is not all that
easy when you allow separate set() methods for individual properties,
and avoiding creating things in the database until it is validated can
also be messy. It basically means you have to structure your model
objects to accept all of their data in one call, or else have a standard
check before saving to the database. You also need a way for them to
tell you which part of the data was wrong.
Although the model is the place that makes the most sense, handy tools
like Data::FormValidator are hard to resist for data validation, even
though the controller (or action, or whatever you want to call it) is
the wrong place for information about the data a model object needs.
Maybe integrating this into Class::DBI would help. I see that
Class::DBI::FromForm is trying to do something like that.
- Perrin
_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole
This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT