Domain object validation vs view model validation
Posted
by
Brendan Vogt
on Stack Overflow
See other posts from Stack Overflow
or by Brendan Vogt
Published on 2010-12-21T12:42:52Z
Indexed on
2010/12/21
12:54 UTC
Read the original article
Hit count: 215
I am using ASP.NET MVC 3 and I am using FluentValidation to validate my view models. I am just a little concerned that I might not be on the correct track. As far as what I know, model validation should be done on the domain object. Now with MVC you might have multiple view models that are similar that needs validation. What happens if a property from a domain object occurs in more than one view model? Now you are validating the same property twice, and they might not even be in sync. So if I have a User domain object then I would like to do validation on this object. Now what happens if I have UserAViewModel and UserBViewModel, so now it is multiple validations that needs to be done.
The scenario above is just an example, so please don't critise on it.
© Stack Overflow or respective owner