Where does input validation belong in an MVC application?
问题 I have a MVC application that receives an input from a form. This is a login form so the only validation that is necessary is to check whether the input is non-empty. Right now before I pass it to the model I validate it in the controller. Is this a best practice or not? Does it belong to the model? 回答1: I don't think there's an official best practice limiting validation to any single part of the MVC pattern. For example, your view can (and should) do some up-front validation using Javascript