问题
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