title: How to implement data validation in model of MVVM?
body: <p>I have an MVVM application which requires data validation. I would like to keep the validation in the model, so the model can be easily reused with other view models without having to duplicate the validation code. Most examples of data validation with WPF either have the validation done in the view model in a MVVM setup, or data validation done in the model when the model is directly bound to the view and a view model is not used. </p>
  
  <p>I would like to have the data validation in my model, have the view model expose my model to the view, and have the view still be able to receive validation feedback from the model. I am planning on either using IDataErrorInfo or Data Annotations for my validation. I have found some examples of this being done, but neither approach seems ideal. </p>
  
  <p>It is accomplished <a href="http://social.technet.microsoft.com/wiki/contents/articles/22660.data-validation-in-mvvm.aspx" rel="nofollow">here</a> with Data Annotations, though it took a moderate amount of custom code.</p>
  
  <p>I like <a href="http://www.eidias.com/Blog/2012/7/2/simple-validation-in-wpf-mvvm-using-idataerrorinfo" rel="nofollow">this</a> approach with IDataErrorInfo better as it does not involve custom code, however I don't know if I am comfortable with the approach taken, where the entire model is exposed as a single property to the view, versus exposing just the required individual properties.</p>
  
  <p>Is there a better or more recommended way to accomplish this?</p>