Javascript 如何在EXPRESS-VALIDATOR中有条件地返回自定义错误消息

Javascript 如何在EXPRESS-VALIDATOR中有条件地返回自定义错误消息,javascript,node.js,express,express-validator,Javascript,Node.js,Express,Express Validator,在我的情况下,如果传递给oneOf()的check()s无法通过验证,则express validator将返回其自定义消息无效值。但是,我希望它以某种方式返回我指定的自定义错误消息,在每次失败的检查中 以下是我的中间件: [ check(`username`, `username is required`) .not() .isEmpty(), oneOf([ check(`pass

在我的情况下,如果传递给
oneOf()
check()
s无法通过验证,则express validator将返回其自定义消息
无效值。但是,我希望它以某种方式返回我指定的自定义错误消息,在每次失败的
检查中

以下是我的中间件:

    [
        check(`username`, `username is required`)
            .not()
            .isEmpty(),
        oneOf([
            check(`password`, `password is required`)
                .not()
                .isEmpty(),
            check(`password`, `password is too short`).isLength({ min: 3 })
        ])
    ]

我希望它返回
密码是必需的
密码太短
,而不是
无效值
。谢谢

(,)
函数之一的第二个参数可以是覆盖默认无效值的消息@Molda我需要一条消息,具体取决于哪个
检查失败