开发者

does dataannotations violate separation of concerns? - asp.net mvc

开发者 https://www.devze.com 2023-01-28 17:05 出处:网络
In asp.net mvc, when I 开发者_StackOverflowhave my custom validations and validation messages using dataannotations in Model, does it not violate separation of concerns? ie: the custom validation migh

In asp.net mvc, when I 开发者_StackOverflowhave my custom validations and validation messages using dataannotations in Model, does it not violate separation of concerns? ie: the custom validation might be related to a business logic, and error message might have to be validated using view specific parameters like localization?

What is your opinion and views on this. And what best way to have validations on data while having good separation of concerns?


I agree it does violate separate to some extent, but sometimes it's better not to be a 100% purist. Doing validation through annotations attached to your model will ensure consistency throughout all views that represent that model data.

0

精彩评论

暂无评论...
验证码 换一张
取 消