我想用JOI為我的自定義驗證設定一個自定義的錯誤資訊,但這不起作用
field: Joi.string()
.required()
.custom((value, helper) =>/span> {
if (!isValidField(value)) {
return helper.message({'any.custom': 'This value is Invalid'})。)
}
return值。
}),
uj5u.com熱心網友回復:
我用這段代碼解決了這個問題
field。Joi.string()
.required()
.custom((value, helper) =>/span> {
if (isValidField(value)) {
return value。
}
return helper.message({ custom: 'This value is Invalid' })。)
})
在這個鏈接上找到了答案。https://github.com/sideway/joi/issues/2235
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/311788.html
標籤:
