[Library | Trunk]: Email validator change regex

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59225 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2020-08-06 10:56:51 +00:00
parent 405f5e6017
commit 64682b91a3
1 changed files with 2 additions and 9 deletions

View File

@ -3,7 +3,7 @@ import {Email} from "./email";
export class Validator {
//private static regex = "^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$";
private static regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
private static regex = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/;
/*
private static regex2= /^(([^<>()\[\]\\.,;:\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,}))$/;
// for expanation paste it in https://www.regextester.com/
@ -13,21 +13,14 @@ export class Validator {
public static hasValidEmails(data: any): boolean {
for(let i = 0; i < data.length; i++) {
if (!this.emailValidator(data[i])) {
// TODO remove console message after final testing
//console.log("INVALID EMAIL: "+data[i]);
return false;
}
}
// TODO remove console message after final testing
//console.log("ALL EMAILS ARE VALID");
return true;
}
public static emailValidator(email: any): boolean {
if (email.match(this.regex))
return true;
else
return false;
return !!email.match(this.regex);
}
}