Controllers usually process request data (GET / POST) and detect invalid forms, CSRF, missing fields, etc., for which the model should not bother. This is the most likely place where you write the bulk of your filter code; validation should only take place until the check for early failure has been verified (for example, do not send an email address to the model if it is not a valid email address).
Your domain’s objects can also provide validation checks (even filtering), which will reduce the responsibility of the dispatcher, but in most cases it’s easier for me personally to work with the model based on the contract (the model assumes that you pass legitimate values) because it’s easier to directly translate validation issues into certain form fields.
The model itself can also perform validation, although it differs from the above input filtering (and checking the type of content); for example, it can check if an email exists in the database, and not check its valid email address.
source share