Skip to content

Add default status 400 to error thrown by Joi.assert() #753

@felixfbecker

Description

@felixfbecker

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 :)

Metadata

Metadata

Assignees

Labels

bugBug or defectfeatureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions