title: How can I do a data type validation on a field that is dependent on another field?
body: <p>I am having trouble performing <strong>data type validation</strong> which is dependent on another field. Most of the examples I found here are for making a field required or not based on a value of another field (<code>MaidenName</code> will be required only if <code>IsMarried</code> is <code>true</code>).</p>
  
  <p>My Model</p>
  
  <pre><code>public class AttributeValuesModel
  {
      public IList&lt;AttributeModel&gt; Values {get; set;}
  }
  
  public class AttributeModel
  {
      [Required]
      public string AttributeName {get; set;}
  
      [Required]
      public string AttributeValue {get; set;}
  
      [Required]
      public int DataTypeId {get; set;}
  }
  </code></pre>
  
  <p>What I would like to do is to validate the user input for AttributeValue based on the value of DataTypeId. For clarity, the value of <code>DataTypeId</code> is known before I even show the view to the user.</p>
  
  <pre><code>    //Possible values for DataTypeId are 
      //1 for decimal
      //2 for dates
      //3 for integer
  </code></pre>
  
  <p>Is this possible?</p>