title: How to set validation annotations order in C#
body: <p>I introduced two annotations on <code>date</code> attribute. One is to validate the date range (e.g. from 1 days later to 15 days later), the other is to validate the time range (e.g. from 8.30am to 4.30pm). If the value meets neither of the two validations, I want the web page to prompt the errormessage of <code>CustomDateRange</code> rather than <code>CustomTimeRange</code>. For now, the opposite situation happens.</p>
  
  <pre><code>    [Required]
      [CustomDateRange(ErrorMessage = "Your reservation time should be at least 24 hours and at most 15 days in advance.")]
      [CustomTimeRange]
      public DateTime? date { get; set; }
  
  public class CustomDateRangeAttribute : RangeAttribute
  {
      public CustomDateRangeAttribute() : base(typeof(DateTime), DateTime.Now.AddDays(1).ToString(), DateTime.Now.AddDays(15).ToString())
      { }
  }
  
  public class CustomTimeRangeAttribute : ValidationAttribute
  {
      protected override ValidationResult IsValid(object value, ValidationContext validationContext)
      {
          try
          {
              DateTime dt = (DateTime)value;
              TimeSpan ts = dt.TimeOfDay;
              TimeSpan start = new TimeSpan(8, 30, 0);
              TimeSpan end = new TimeSpan(16, 30, 0);
              if (ts &gt;= start &amp;&amp; ts &lt;= end)
              {
                  return ValidationResult.Success;
              }
              else
              {
                  return new ValidationResult("Your reservation time should be with in the openning hours, which is from 8.30am to 4:30pm.");
              }
          }
          catch (Exception e)
          {
              return new ValidationResult("Invalid time input!");
          }
      }
  }
  </code></pre>