Where and how to validate and map ViewModel?

Posted by chobo on Stack Overflow See other posts from Stack Overflow or by chobo
Published on 2010-05-07T05:54:39Z Indexed on 2010/05/07 5:58 UTC
Read the original article Hit count: 315

Hi, I am trying to learn Domain Driven Design and recently read that lots of people advocate creating a ViewModels for your views that store all the values you want to display in a given view.

My question is how should I do the form validation? should I create separate validation classes for each view, or group them together? I'm also confused on what this would look like in code.

This is how I currently think validation and viewmodels fit in to the scheme of things:

View (some user input) -> Controller -> FormValidation(of ViewModel) -> (If valid map to ViewModel to Domain Model) -> Domain Layer Service -> Infrastructure

Thanks!

P.S. I use Asp.net MVC with C#

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about domain-driven-design