首页 > 解决方案 > 如何在 express-validator 中访问自定义通配符验证中的对象

问题描述

我想在自定义通配符验证中访问对象

body('inputs.*.minimum')
    .custom((value, { req, path }) => {
         const maxValue = body('inputs.*').maximum
         return Number(value) <= Number(maxValue)
    })
    .withMessage('error message'),

我尝试使用上述方法但无法获得maxValue

我也发现了这个,但不想使用lodash

标签: javascriptnode.jsexpress-validator

解决方案


推荐阅读