Closed palazzetti closed 4 years ago
You'd want to throw a Joi Validation error in your first screenshot, not a built in Error
object. Also, if you're just trying to control the message, check out the .message()
API.
You'd want to throw a Joi Validation error in your first screenshot, not a built in
Error
object. Also, if you're just trying to control the message, check out the.message()
API.
route.post("/register", celebrate({
[Segments.BODY]: Joi.object({
name: Joi.string().$.min(3).max(24).message('error message info'),
})
}), async (req, res) => {
res.json({});
});
😁
node
version - 14.5.0celebrate
version - 13.0.2joi
version (vianpm ls --depth=0 | grep joi
) -17.2.1My
joi
schema looks like this:Here is an example value that is not working as expected:
The issue I am having with
celebrate
is:After the update to celebrate 13.x, when is time to throw the error from joi i get the above error. From what I understand, the error generated by Joi doesn't like to celebrate. I've already tried using CelebrateError without success. Thanks.