title: Change Validation For a Property in ASP.NET MVC 3 by Condition
body: <p>This is my Model:</p>
  
  <pre><code>[RegularExpression(@"^08[589][0-9]{8}$", ErrorMessage = "Invalid Number!")]
  public string Phone { get; set; }
  
  [ForeignKey]
  public long PhoneType { get; set; } // 1-CellPhone , 2-Phone
  </code></pre>
  
  <p>So I think to change <code>RegularExpression</code> Validation by Change <code>PhoneType</code> if I want say more specific:</p>
  
  <p>if user select <code>CellPhone</code> from <code>DropDownList</code> the validation be </p>
  
  <pre><code>[RegularExpression(@"^08[589][0-9]{8}$", ErrorMessage = "Invalid Number!")] 
  </code></pre>
  
  <p>and if select <code>Phone</code> the validation be </p>
  
  <pre><code> [RegularExpression("^[1-9][0-9]{9}$", ErrorMessage = "Invalid Number!")]
  </code></pre>
  
  <p>What is your suggestion?</p>