I have (I hope) a very simple question for experts in the MVC framework:
Where to apply input filtering and validation? Controller or model?
I read a lot of guides and guides on filtering user input, but did not notice a lot of discussion where it should be applied. Using forms is simple, in fact almost everything is done for you by Zend_Form through Zend_Filter and Zend_Validate.
But when I need to filter out one value from user input and pass it to the model, what is the best way to clean it before passing it to the model or the model itself?
Suppose I create a model that other people will use, and it does important work on the file system. I am 100% sure that other people will prepare the parameters correctly before passing them to the model? I am not, so it would be best to clear the parameters in the model itself.
But these are just my thoughts, and, as I said, I would like to hear yours, directly from the masters of the profession;)
A good day.
source
share