0

我正在尝试验证电子邮件数组。我可以使用此方法验证电子邮件,但我无法获得任何结果并且我使用 adonis 4.1.0 我返回 mail_array_check 它收到一条错误消息,但所有邮件都是正确的,它正在收到正确的邮件。

const user = await auth.getUser();
const mails = request.all().mails;
const receivers_mails = JSON.parse(mails);
const mail_array_check = await receivers_mails.filter(async m => {
  const rules1 = {m: 'email'};
  const validation1 = await validateAll(m, rules1)
  if (validation1.fails()) {
    return response.status(400).send({status: false, message: validation1.messages()})
  }
});
4

1 回答 1

1
for( var  i=0; i < receivers_mails.length; i++){
  this.passMails = typeof `${receivers_mails[i]}` ==='string' && /^[\w+\d+._]+\@[\w+\d+_+]+\.[\w+\d+._]{2,8}$/.test(`${receivers_mails[i]}`);
  if(this.passMails === false){
    return response.status(400).send({
      message:"Invalid Sender email address, Please check sender email address!",
      status:false
    })
  }
}
于 2020-09-04T08:58:10.617 回答