电子邮件数组验证 Adonis js
Email array validation Adonis js
我正在尝试验证电子邮件数组。我可以使用此方法验证电子邮件,但我无法获得任何结果并且我使用 adonis 4.1.0 I return 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()})
}
});
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
})
}
}
我正在尝试验证电子邮件数组。我可以使用此方法验证电子邮件,但我无法获得任何结果并且我使用 adonis 4.1.0 I return 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()})
}
});
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
})
}
}