【发布时间】:2022-02-16 01:11:02
【问题描述】:
参数验证 我想确保数组不能为空,以便验证数组
imgList= [ { “文件类型”:“png”, “文件内容”:“base64” }, { “文件类型”:“png”, “文件内容”:“base64” } ] 我想验证键和值是否存在(不应该为空)
eg: filetype is missing
{
"fileContent": "base64"
},
eg2: value is missing
{
"fileType": "",
"fileContent": "base64"
},
我厌倦的代码是
body.imgList.forEach((item) => {
var key,
count = 0;
for (let [key, value] of Object.entries(item)) {
if (item.hasOwnProperty(key) && !!value) {
count++;
}
}
var objectLenght = count;
if (objectLenght != 2) {
return cb({"status_code":400,"status":"Pass all the required fields"});
}
});
当我尝试这个工作时,它已经死了,并且上传的图片没有在 s3 中输入
【问题讨论】: