我正在尝试使用express-validator验证一个手机号码正则表达式。
我浏览了docs api,但找不到检查正则表达式的验证器函数。使用regex.test()会像下面这样工作吗?
body('mobile', 'Invalid mobile number.')
.escape()
.exists({checkFalsy: true})
.isLength({min: 11, max:11})
.regex.test(/^(\+123)\d{11}$/)发布于 2020-07-22 09:42:49
我在express-validator中找到了.matches()验证器函数,它相当于regex.test()。
body('mobile', 'Invalid mobile number.')
.escape()
.exists({checkFalsy: true})
.isLength({min: 11, max:11})
.matches(/^(09|\+639)\d{9}$/)https://stackoverflow.com/questions/63011105
复制相似问题