2018-12-17 16:15:14 +01:00
|
|
|
import {Email} from "./email";
|
|
|
|
|
|
|
|
export class Validator {
|
|
|
|
|
|
|
|
private static regex = "^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$";
|
|
|
|
|
|
|
|
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");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO remove console message after final testing
|
|
|
|
console.log("ALL EMAILS ARE VALID");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static emailValidator(email: any): boolean {
|
2018-12-18 13:33:18 +01:00
|
|
|
if (email.match(this.regex))
|
2018-12-17 16:15:14 +01:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|