Skip to content

Throw typed errors #1244

@hulbert

Description

@hulbert

As far as I can tell (primarily from reading docs), there's no obvious capability for checking instanceof on a Joi ValidationError.

This makes writing assertions with Code difficult, e.g. I'd like to able to do something like:

const Joi = require('joi')
const expect = require('code').expect

function throws() {
    Joi.assert('x', Joi.number())
}

expect(throws).to.throw(Joi.ValidationError)

Am I missing something? If not, thoughts on adding this capability?

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvementsupportQuestions, discussions, and general support

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions