In the MVC Standard, the Model is responsible for the business layer, in which will be the business rules and validations. I have a question about the following. A method in the controller that receives any parameter (it can be a primitive type or an object). It calls the model to perform an action (such as persisting in the database, changing or deleting).
The first question: should Model expect the parameter to be correct? That is, should there be a validation in the controller to know if the parameter came correctly or should you pass the parameter to the Model as it was sent to the controller and the Model must do this validation?
The second doubt: if the Model does parameter validation how should the return be handled? Let's say the action is to insert a new entity into the database. And the default is to return the ID of this entity on success. In case of error, what would be the best decision, return 0 as an error, throw an exception and return 0, or would it be better to refactor these actions so that they return something that can be used both on success and on return? / p>
I'm working on a project made in Silex with Doctrine DBAL, but that was not done by me and I'm having these doubts because I see that the application does not follow a correct and standardized flow in these situations. Here the controller has more responsibility than Model and this has made me evaluate refactoring.