Welcome Guest, Not a member yet? Register   Sign In
Data validation and processing. In controller or model? Getting error back to controller. Exceptions?
#2

[eluser]Aken[/eluser]
I always do form validation in the controller. That's what the controller is for, in my opinion - handling input data and delegating it appropriately. I also have never run into a situation where I needed to reuse the exact same form validation in more than one controller.

That said, I also do basic validation/sanitizing in my models, that prevent improperly formatted data from affecting code in my model. Depending on the severity of the error (and the type of project I'm doing, sometimes), I'll throw an Exception (severe error) or save the error to a property and return false. At which point I can call Model->getError() or what have you if I need. It's really up to you; there's no defined best practice there.


Messages In This Thread
Data validation and processing. In controller or model? Getting error back to controller. Exceptions? - by El Forum - 10-29-2012, 04:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB