Closed incompletude closed 4 years ago
I think the best way to give validation error a proper bad request response is to check if error is a instance of ValidationError, but I could not find a way to import the object.
try { const person = await PersonService.create(req.body) res.json({ result: true, message: 'Person created.', token: person.token }) } catch (error) { if (error instanceof ValidationError) { doSomething() return } next(error) return }
I think this info should be in the documentation. Do you mind clarifying me?
I can open a PR to add this and fix a few other errors.
Yes, you are right. It's not yet in the documentation. Your store has access to the ValidationError Class via store.ValidationError.
ValidationError
store.ValidationError
I think the best way to give validation error a proper bad request response is to check if error is a instance of ValidationError, but I could not find a way to import the object.
I think this info should be in the documentation. Do you mind clarifying me?
I can open a PR to add this and fix a few other errors.