I have a class in my api that contains an id and DateTime property.
public class MyTestClass
{
public int id { get; set; }
public DateTime dateTime { get; set; }
}
I was wondering if there is a way to accept only a JSON string that has a specific date format. My problem is that the model binder will parse both "21-01-1991" and "01-21-1991".
sample API controller
public void Post(MyTestClass myTest)
{
DateTime x = myTest.dateTime;
}
I want the api to return bad request in case the user sent the dateTime property in any format other than the iso 8601 format.