'Angular Form Validators incorrect email validation

When using Angular Form Validators ( import { FormControl, FormGroup, Validators } from '@angular/forms'; ) from the official Validators with the following command:

Validators.email

The email validation is only very rudimentary and therefore wrong. For Angular Validators this: "email@t" is a correct email adress, what is wrong of course.



Solution 1:[1]

The solution is using "Validators.pattern" instead of "Validators.email".

Validators.pattern('^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$')

This code will test the input of an correct email syntax.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1