Validation: in presentation tier, middle tier or data tier?
Posted: Wed Aug 26, 2009 9:20 am
Hi,
I'm trying to improve a re-usable Form class I've designed - a little pet project. It's the only piece of code I always end up re-using.
I believe in separation of concerns, and maximum re-use, but like to keep it simple - avoiding frameworks wherever possible.
But I'm having trouble working out where to do certain types of validation. For example, checking for a valid email address. Which tier should this be done at? Presentation, middle or data? Once, twice, or even in all three? Ultimately the error needs to be displayed to the user via the Form object.
Any thoughts very welcome!
I'm trying to improve a re-usable Form class I've designed - a little pet project. It's the only piece of code I always end up re-using.
I believe in separation of concerns, and maximum re-use, but like to keep it simple - avoiding frameworks wherever possible.
But I'm having trouble working out where to do certain types of validation. For example, checking for a valid email address. Which tier should this be done at? Presentation, middle or data? Once, twice, or even in all three? Ultimately the error needs to be displayed to the user via the Form object.
Any thoughts very welcome!