gpt4 book ai didi

node.js - 检查空值快速验证器

转载 作者:太空宇宙 更新时间:2023-11-03 23:47:53 25 4
gpt4 key购买 nike

我正在使用快速验证器来验证服务器上的发布数据。事情工作正常,但当我尝试检查空值时,它不起作用..

我已经尝试过

req.checkBody('title', 'Title is required').isLength({ min: 1, max:50 });

req.checkBody('title', 'Title is required').trim().notEmpty();

对于两个空值都保存到数据库。

如何在快速验证器中检查空值?

最佳答案

req.checkBody('title', 'Title is required').exists({checkFalsy: true}).isLength({ min: 1, max:50 });

关于node.js - 检查空值快速验证器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60370957/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com