validator.ts: Add uppercase letters as accepted characters in emails | Bug fix for not accepting email with a singe dot after '@'.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@54672 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-01-30 13:57:21 +00:00
parent a6ff2cf0e0
commit a6497d2dcc
1 changed files with 8 additions and 2 deletions

View File

@ -2,13 +2,19 @@ import {Email} from "./email";
export class Validator {
private static regex = "^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$";
//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 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/
// RFC5322 https://emailregex.com/
*/
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");
console.log("INVALID EMAIL: "+data[i]);
return false;
}
}