Zoh*_*ion 5 node.js express express-validator
options = ['asdasda', 'asdasdas', 'asdasdasafsaafasfasfasfasfasfasasasasasdas', 'asd'];
req.check('options', 'Option must not exceed 30 characters').isLength({max: 30});
Run Code Online (Sandbox Code Playgroud)
我正在尝试验证数组选项中的每个字符串。有什么办法吗?
是的,您必须为此使用通配符。
req.check('options.*').isLength({ max: 30 })
Run Code Online (Sandbox Code Playgroud)