Check dates are valid before searching database, otherwise return an HTTP 400 status code.