title: Conditionally validating portions of an ASP.NET MVC Model with DataAnnotations?
body: <p>I have certain panels on my page that are hidden under certain circumstances.</p>
  
  <p>For instance I might have a 'billing address' and 'shipping address' and I dont want to validate 'shipping address' if a 'ShippingSameAsBilling' checkbox is checked.</p>
  
  <p>I am trying to use the new <a href="http://weblogs.asp.net/scottgu/archive/2009/07/31/asp-net-mvc-v2-preview-1-released.aspx" rel="nofollow noreferrer">DataAnnotations capabilities</a> of ASP.NET MVC 2 (preview 1) to achieve this.</p>
  
  <p>I need to prevent validation of the 'shipping address' when it is not displayed and need to find the way way to achieve this. I am talking mainly server side as opposed to by <a href="https://stackoverflow.com/questions/1316602">using jquery</a>.</p>
  
  <p>How can I achieve this? I have had several ideas, related to custom model binding but my current best solution is below. Any feedback on this method?</p>