Changed email validator to accept uppercase
This commit is contained in:
@@ -5,8 +5,12 @@ const EMAIL_REGEX = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/;
|
|||||||
|
|
||||||
export function EmailValidator(label = 'Fältet'): ValidatorFn {
|
export function EmailValidator(label = 'Fältet'): ValidatorFn {
|
||||||
return (control: AbstractControl): ValidationError => {
|
return (control: AbstractControl): ValidationError => {
|
||||||
if (control && control.value && !EMAIL_REGEX.test(control.value)) {
|
if (control && control.value) {
|
||||||
return { type: 'invalid', message: `Ogiltig ${label}` };
|
const value: string = control.value as string;
|
||||||
|
|
||||||
|
if (!EMAIL_REGEX.test(value.toLowerCase())) {
|
||||||
|
return { type: 'invalid', message: `Ogiltig ${label}` };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -16,7 +20,7 @@ export function EmailValidator(label = 'Fältet'): ValidatorFn {
|
|||||||
export function CommaSeparatedEmailValidator(): ValidatorFn {
|
export function CommaSeparatedEmailValidator(): ValidatorFn {
|
||||||
return (control: AbstractControl): ValidationError => {
|
return (control: AbstractControl): ValidationError => {
|
||||||
if (control && control.value) {
|
if (control && control.value) {
|
||||||
const values: string[] = (control.value as string).trim().split(',');
|
const values: string[] = (control.value as string).toLowerCase().trim().split(',');
|
||||||
const invalidEmailaddresses = [];
|
const invalidEmailaddresses = [];
|
||||||
|
|
||||||
values.forEach(value => {
|
values.forEach(value => {
|
||||||
|
|||||||
Reference in New Issue
Block a user