我试图用express-validator v4.3.0
验证输入来验证快速输入。我试图按照文档进行操作,但无法正常工作......它没有检测到任何错误。它也停在路线上。我想我错过了next()
函数调用。我错过了什么?
这是我的路线:
routes.get(
"/localizations/apps/:app_name/locales/:locale_abbr_short",
validateParams,
fetchLocalization,
)
这是validateParams
:
export async function validateParams() {
const allowedAppNames = ['common','webcalc_v2']
const allowedLocales= ['dk']
return [
check('app_name').isIn(allowedAppNames).withMessage('App name is unknown').trim(),
check('locale_abbr_short').isIn(allowedLocales).withMessage('Locale is unknown').trim(),
check('provider').isNumeric().withMessage('Provider id must be a number').trim(),
]
}