Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Mathias Verraes:
Form, Command, and Model Validation
Feb 17, 2015 @ 18:34:38

In his new post Mathias Verraes talks about the separation of concerns that, in his opinion, should exist between form, command and model and the validation of each.

Many of the frameworks I’ve worked with, promise to separate responsibilities with MVC. In practice, the end up coupling everything to everything. The forms are coupled to the models, and there’s a grand unified validation layer. This may be convenient at first, but it breaks down for larger systems, and creates headaches when having to support multiple clients. My approach is to clearly separate the validation for the form itself, from the Command validation and the model validation.

He talks about each of the different types in turn, starting with Commands. He suggests that the validation should happen in Value Objects in the Commands, validation rules in Models and some client-side validation (backed up by backend checking, of course) via Javascript or HTML5 fields.

tagged: form command model validation separation concerns valueobject

Link: http://verraes.net/2015/02/form-command-model-validation/


Trending Topics: