title: creating dynamic controls with mvc4 and apply validation to only some fields
body: <p>I am using MVC4 to build an application that is a question generator allowing a user to ask a bunch of questions and to set with a true/false if they are required or not.</p>
  
  <p>I am now onto the part of generating the questions ready for a user to answer the questions.</p>
  
  <p>I want to enable both serverside and clientside validation.</p>
  
  <p>What is the best approach for applying required fields to the questions that have been set to required?</p>
  
  <p>If I have a simple model and view model like</p>
  
  <pre><code> public class TestModel
  {
      public Guid Id { get; set; }
      public string Question { get; set; }
      public bool Required { get; set; }
  }
  
  public class TestViewModel
  {
      public string TestName { get; set; }
      public List&lt;TestModel&gt; Tests { get; set; }
  }
  </code></pre>
  
  <p>I can't just add a [Required] Attribute to the Question property</p>
  
  <p>Is it possible to apply validate only to qeustions where the Required property is set to true?</p>