joi string custom validation fuction
const customValidator = (value, helpers) => { if (!isAddress(value)) { return helpers.message("Invalid address"); } else { return value; } }; const createSchema = Joi.object({ address: Joi.string() .required() .custom((value, helper) => customValidator(value, helper)), key: Joi.string().required(), index: Joi.string().required(), });