I was trying to set some validations with some custom messages in Joi. So, for example, I have discovered that when a string must have at least 3 characters we can use "string.min" key and associate this to a custom message. Example:
username: Joi.string().alphanum().min(3).max(16).required().messages({
"string.base": `Username should be a type of 'text'.`,
"string.empty": `Username cannot be an empty field.`,
"string.min": `Username should have a minimum length of 3.`,
"any.required": `Username is a required field.`,
}),
Now here is my question:
Question
// Code for question
repeat_password: Joi.ref("password").messages({
"string.questionHere": "Passwords must match each other...",
}),
What method (questionHere) name need to set to repeat_password to be able to notify the user that passwords must match? I don't even know if Join.ref("something") accept .messages({...})...
If someone could please show me some help in the Joi docs, I haven't find anything yet by there...