I am using ASP.NET MVC 3 and I am using FluentValidation to validate my view models. I'm just a little worried that I may not be back. As far as I know, model validation should be performed on a domain object. Now with MVC, you can have several view models that are similar, which requires verification. What happens if a property from a domain object occurs in more than one view model? Now you double-check the same property, and they may not even synchronize. Therefore, if I have a user domain object, I would like to do a check on this object. Now, what happens if I have a UserAViewModel and UserBViewModel, so now I need to do a few checks.
In my News class, I have a Title property, which is required. In my view model, I also have a Title property, I use AutoMapper to display news and NewsViewModel. So this check happens twice. When is a domain model validated and when is a model validated?
The script above is just an example, so please do not criticize it.
validation asp.net-mvc fluentvalidation
Brendan vogt
source share