This is a quick question related to Symfony, but may be a general MVC question.
I have a class in my model, for example, WebUser . This class has the email_address property. This value must be unique for each WebUser .
Now I have made all my Symfony forms confirm that email_address is unique to this WebUser , however I am wondering if I should add this check for the model?
But it also made me wonder if you really should check each set() method in the model? It seems like a reasonable enough decision to make sure that there are no erroneous data in the database, but most (if not all) of the data should go through the controllers, which also check. So it seems to me that I am doing the same check twice, and that just seems pointless?
What do you think about this? I still tend to validate in the model, because it makes the most sense, because it dictates the business logic.
If you have to check in the model, how did you choose the appropriate set() error in Symfony, which is correctly handled by the form framework?
Thanks.
php validation model-view-controller symfony1
Stephen melrose
source share