Every line of 'angular 4 email validation pattern' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
15 public static emailValidator(control: AbstractControl): boolean { 16 // RFC 2822 compliant regex 17 /* tslint:disable */ 18 if (control.value.match(/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/)) { 19 /* tslint:enable */ 20 return false; 21 } 22 return true; 23 }
13 validate(c: AbstractControl): { [key: string]: any } { 14 let regExp: RegExp = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; 15 16 return regExp.test(c.value) ? undefined : { 17 validateEmail: { 18 valid: false, 19 }, 20 }; 21 }}
5 static validate(control: Control): {[key: string]: any} { 6 var regexp = new RegExp("^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$", 'i'); 7 8 if (!regexp.test(control.value)) { 9 return {invalidEmail: true}; 10 } 11 12 return null; 13 }
10 function validateEmail (email) { 11 if (email && email.match(/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i)) { 12 return true 13 } 14 15 return false 16 }
2 function validateEmail(email){ 3 var emailReg = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); 4 return emailReg.test(email); 5 }
21 public static validateEmail(email: string): Boolean { 22 // tslint:disable:max-line-length 23 const regExp = /^(([^<>()[\]\\.,;:\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,}))$/; 24 return regExp.test(email); 25 }
20 function validate_email(email) 21 { 22 var emailReg = /\S+@\S+\.\S+/; 23 24 if(!emailReg.test(email)) { 25 return false; 26 } 27 28 return true; 29 }
19 public static passwordValidator(control: AbstractControl): any { 20 if (!control.value) { return; } 21 22 // {6,100} - Assert password is between 6 and 100 characters 23 // (?=.*[0-9]) - Assert a string has at least one number 24 // (?!.*\s) - Spaces are not allowed 25 return (control.value.match(/^(?=.*\d)(?=.*[a-zA-Z!@#$%^&*])(?!.*\s).{6,100}$/)) ? '' : { invalidPassword: true }; 26 }
38 addValidators() { 39 super.addValidators(); 40 this.validators.push(EmailValidator); 41 }
225 function validateEmail(email) { 226 if (email.length <= 0) { 227 return false; 228 } 229 var emailPattern = /\S+@\S+\.\S+/; 230 return emailPattern.test(email); 231 }