780 questions
I'm sure Viorel-1 made a typo and is recommending a nullable type.
public class OrderHistoryRequestDto
{
[Required(ErrorMessage = "Please add StartDate to the request.")]
[DataType(DataType.Date)]
public DateTime? StartDate { get; set; }
[Required(ErrorMessage = "Please add EndDate to the request.")]
[DataType(DataType.Date)]
public DateTime? EndDate { get; set; }
}
I tested the model with PostMan and an HTTP GET and received the following validation response.
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-13effc30183cfe634ea13672b70e6373-affffa0f4b34e5f1-00",
"errors": {
"EndDate": [
"Please add EndDate to the request."
]
}
}