I'm currently doing this in my koa app in every route:
let object
try {
object = Joi.attempt(context.request.body, schema)
} catch (e) {
e.status = 400
throw e
}
It would be nice for convenience to have the 400 already on the error since that is the HTTP equivalent of a validation error. I don't think there would be any downsides to this, so please consider :)