Question
How can I customize the error message for a required field in Joi?
Asked by: USER1652
66 Viewed
66 Answers
Answer (66)
Use the `required()` method along with the `messages` option with the `any.required` error code: `Joi.string().required().messages({'any.required': 'This field is mandatory.'})`.