title: 500 Internal Server Error when Regex fails in C# data annotation asp.net core 2
body: <p>I added a Regular Express on a model property using data annotation to validate date string. It works fine when date string is a valid date {dd/mm/yyyy}, but returns 500 internal server error when an invalid date string is entered.</p>
  
  <p>I want to do the validation by checking if <code>ModelState</code> is valid instead of using <code>DateTime.TryParse</code>. Below is my code snippet</p>
  
  <pre><code>[RegularExpression(@"(((0?|1)[0-9]|2[0-9]|3[0-1])\/(0?[1-9]|1[0-2])\/((19|20)\d\d))$", ErrorMessage = "Invalid date format. Date should be in this format {dd/mm/yyyy}")]
  </code></pre>
  
  <p>Thanks :)</p>