How do I override empty rule with messages in JOI 17?

老子叫甜甜 提交于 2021-02-11 12:19:56

问题


I read Node.js + Joi how to display a custom error messages? and am still having trouble.

I have a schema like this:

const create = validator.object().keys({
  app: validator
    .string()
    .required()
    .valid(...ARRAY_OF_VALUES)
    .messages({'any.unknown':'Must pass valid code'})
});

An update of the question above points at https://github.com/sideway/joi/blob/master/API.md#list-of-errors for the valid error types.

I test with a value of invalid! and still see the default error message. I have tried string.unknown, string.invalid, any.invalid to no avail.

来源:https://stackoverflow.com/questions/66070468/how-do-i-override-empty-rule-with-messages-in-joi-17

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!