4

A short while ago I'm sure I read that is was possible to use AutoMapper to map the validation attributes from the domain model to the view model, i can't find that post any more though!

Has anybody seen any code or know if it would be possible to do this? This would give the added benefit of not repeating validation in both ViewModel + Models.

Paul

s1mm0t
  • 6,035
  • 4
  • 38
  • 45
Paul Hinett
  • 1,951
  • 2
  • 26
  • 40
  • Want to know this as well.... How can I provide, extend or override validationdata for Subsets of models. (im using Entity Framework so I can't Json serialize it... – Rickjaah Aug 03 '10 at 07:55
  • 1
    For reference, this question provides a solution: http://stackoverflow.com/questions/9989785/technique-for-carrying-metadata-to-view-models-with-automapper – Town Sep 25 '12 at 10:09
  • I don't have an answer for you but I am curious; why are you still on MVC 2? See http://www.asp.net/mvc/mvc4 Also http://www.asp.net/vnext/overview/aspnet/whats-new I bet whatever solution you find, a simpler and more elegant one could be found with a later version of MVC. – S.A. Jun 22 '13 at 20:02

0 Answers0