Which layer for model validation data annotations?
Following on from Model layer dependency on MVC attributes, is it a valid design choice to have a project that has the model classes and a separate project that defines the validation for each class?
This validation project would be specific to a particular front end technology, overriding properties and adding annotations.
For example, MVC data annotations. I dont think it makes sense for the model class to have knowledge of a specific front end technology.
While It could be argued in the case of MVC that the validation could simply be defined in view models, there are already view models in place that serve other functions. I was thinking it might be better to define all the validation in its own layer.
I like to make it so my MVC project contains only scripts, content, views, and controllers. I put all of my view models, client-side validation, etc in a Model project.
链接地址: http://www.djcxy.com/p/56590.html上一篇: 自定义数据注释在回发时不显示错误
下一篇: 模型验证数据注释的哪一层?