Guides
Last updated
July 25, 2025

5 Ways to Implement Email Validation in Angular Reactive Forms

Nicolas Rios
Nicolas Rios
Table of Contents:
ON THIS PAGE
Get your free
email validation
 API key now
stars rating
4.8 from 1,863 votes
See why the best developers build on Abstract
START FOR FREE
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required

Proper email validation in Angular reactive forms ensures you collect accurate user data. We will walk through five implementation methods, each with working code. You will also learn about the drawbacks of traditional approaches and how Abstract API helps overcome them without the associated complexity.

How to Implement Email Validation in Angular Reactive Forms

Here are four common methods to validate emails in Angular reactive forms. Each approach has a specific use case, from simple format checks to server-side confirmation of deliverability.

Built-in Validators.email

Angular exposes "Validators.email", a ready-made function that plugs directly into a reactive "FormControl". The implementation uses a WHATWG/RFC-inspired regex. This pattern rejects local parts longer than 64 bytes and addresses longer than 254 bytes. It also rejects local parts that start or end with a dot. Because the validator is synchronous, it executes on every value change. It surfaces "{ email: true }" when the pattern fails, according to the official documentation.

constructor(private fb: FormBuilder) {
  this.form = this.fb.group({
    email: ['', [Validators.required, Validators.email]]
  });
}

Validators.pattern with a Custom Regex

When corporate policy demands a different grammar, you can pass a regex through "Validators.pattern". This is useful for cases where you need to disallow “+” tags or permit only certain TLDs. Angular treats the pattern like any other synchronous validator. The regex can be externalized for reuse or compiled dynamically for white-list scenarios, as shown in community examples.

const companyMail = /^[a-z0-9._%+-]+@acme\.corp$/i;
this.form = this.fb.group({
  email: ['', [Validators.required, Validators.pattern(companyMail)]]
});

Custom Synchronous Validator Function

For logic that goes beyond a single regex, you can implement a custom function. This approach works well to ban disposable domains or mix multiple regular expressions. You implement a closure that returns "ValidationErrors | null". The function can be parameterized or generated by factories for dependency injection friendliness, a common pattern for validation management.

function enterpriseEmailValidator(control: AbstractControl) {
  const value = control.value as string;
  if (!/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/i.test(value)) return {invalidFormat: true};
  const [_, domain] = value.split('@');
  if (['mailinator.com','tempmail.dev'].includes(domain)) return {disposable: true};
  return null;
}
this.form = this.fb.group({
  email: ['', [Validators.required, enterpriseEmailValidator]]
});

Custom Asynchronous Validator

To guarantee not only format but also uniqueness or deliverability, attach an "AsyncValidatorFn". This function typically hits an HTTP endpoint for server-side confirmation. The "updateOn" option prevents the application from contact with the backend on every keystroke. According to the Angular guide, the async validator runs only after all synchronous validators pass. This is a standard way to add async validators.

emailTaken(control: AbstractControl) {
  return this.userSvc.isEmailTaken(control.value).pipe(
    map(isTaken => (isTaken ? {taken: true} : null))
  );
}
this.form = this.fb.group({
  email: ['', [Validators.required, Validators.email], [this.emailTaken.bind(this)]],
}, {updateOn: 'blur'});

Common Challenges in Angular Email Validation

These approaches introduce several maintenance and user experience problems. They range from outdated regular expressions to complex logic for asynchronous server-side checks.

  • The built-in Validators.email uses a limited regex that rejects many valid but unusual addresses. It also allows some non-deliverable strings to pass, which forces engineers to write fragile custom validators for proper checks.
  • Hard-coded patterns in Validators.pattern or custom functions quickly become outdated. They fail to validate new TLDs and internationalized domains, which require constant manual updates to the regex to remain effective.
  • Custom asynchronous validators for deliverability checks introduce complexity. They require extra observables, cancellation logic, and error handlers to manage network latency and avoid race conditions, which complicates form state management.
  • Complex regexes used in Validators.pattern create performance and security risks. A crafted input can cause a Regex-DoS attack that freezes the application. Developers also face mismatches between online testers and Angular’s pattern parser.

Validate Emails with Abstract API
Improve user sign-ups and data accuracy in your Angular reactive forms with proper email validation.
Get started for free

How Abstract API Handles Email Validation in Angular Reactive Forms

Abstract API addresses the core weaknesses of traditional methods through a comprehensive, real-time validation call that replaces limited, pattern-based checks.

  • A single HTTPS request returns a full deliverability analysis, a quality score, and multiple boolean flags for details like disposable or role-based addresses. This process completes in about 50 milliseconds without open ports or custom lists.
  • The validation logic receives continuous updates through machine learning, so it evolves independently of your application's code.
  • Its pure JSON response integrates easily into an AsyncValidator. The error object can hold the full API payload, which allows for granular feedback in the user interface.
  • A consistent API surface works the same on both the front-end and back-end, which eliminates separate validation paths.

How to Add Abstract API to Your Dev Environment

Once you understand Abstract’s capabilities, you can add its email validation API to your project with ease.

  • Sign up at Abstract and generate an Email Validation API key.
  • Execute npm install @angular/common@latest if your project does not already possess it.
  • Add HttpClientModule to the imports array of your AppModule.
  • Create an EmailValidationService that performs a GET request to the Abstract API endpoint with your api_key and the email as query parameters.
  • Implement emailDeliverabilityValidator as an AsyncValidatorFn. It calls the validation method and returns null for DELIVERABLE addresses, or an error object otherwise.
  • Attach the validator to your form control with an updateOn property set to "blur".
@Injectable({providedIn:'root'})
export class EmailValidationService {
  private url = 'https://emailvalidation.abstractapi.com/v1/';
  constructor(private http: HttpClient) {}
  validate(email: string) {
    return this.http.get<any>(this.url, {params: {api_key: environment.abstractKey, email}});
  }
}

export const emailDeliverabilityValidator =
  (svc: EmailValidationService): AsyncValidatorFn => (ctrl) =>
    svc.validate(ctrl.value).pipe(
      map(r => r.deliverability === 'DELIVERABLE' && !r.is_disposable_email.value ? null : {abstractEmail: r}),
      catchError(() => of({abstractEmail: {error: 'apiFailure'}}))
    );

Sample Email Validation Implementation with Abstract API

The code above creates a custom asynchronous validator in Angular. It sends the user's email to the Abstract API endpoint and then inspects the JSON response. If the "deliverability" field is "DELIVERABLE" and the "is_disposable_email" flag is "false", the validator returns null, which signals a valid state. Otherwise, it returns an error object that contains the full API response. This allows your user interface to display specific feedback. Below is a sample response for a valid email.

{
 "email":"johnsmith@gmail.com",
 "autocorrect":"",
 "deliverability":"DELIVERABLE",
 "quality_score":0.9,
 "is_valid_format":{"value":true,"text":"TRUE"},
 "is_free_email":{"value":true,"text":"TRUE"},
 "is_disposable_email":{"value":false,"text":"FALSE"},
 "is_role_email":{"value":false,"text":"FALSE"},
 "is_catchall_email":{"value":false,"text":"FALSE"},
 "is_mx_found":{"value":true,"text":"TRUE"},
 "is_smtp_valid":{"value":true,"text":"TRUE"}
}

Final Thoughts

Traditional email validators only check for a correct format. They cannot detect bounced addresses, temporary domains, or typos, an approach that pollutes your database.

Abstract API replaces these limited checks with a real-time call that confirms deliverability. For reliable user email validation, consider an account on Abstract API to get your free API key.

Validate Emails with Abstract API
Ensure every email is valid. Protect your forms from bad data and improve user sign-ups.
Get started for free

Related Articles

Phone Validation
key now
Get your free
stars rating
4.8 from 1,863 votes
See why the best developers build on Abstract
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required