validate email using regex

This commit is contained in:
GotPPay
2018-01-19 20:05:49 +01:00
parent 0727328e58
commit 00272ec67d
2 changed files with 9 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
const nodemailer = require ('nodemailer');
module.exports = {
validateEmailFromAlexaResponse: function (email) {
transformEmailFromAlexaResponse: function (email) {
//email from alexa response will contain words instead of symbols, like :
//at = @
//underscore = _
@@ -14,10 +14,13 @@ module.exports = {
.replace (/dash/gi, '-')
.replace (/dot/gi, '.');
//Validate here with some email validation regex
return transformedEmail;
},
//return true if email is valid
return true;
isEmailValid : function(email){
let validEmailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return validEmailRegex.test(email);
},
sendEmal: function (name, fromEmail, message, toEmail) {