added functionality to send 400 as bad request code if validation fails