This is the archived documentation for Angular v5. Please visit angular.io to see documentation for the current version of Angular.

EmailValidator

npm Package @angular/forms
Module import { EmailValidator } from '@angular/forms';
Source forms/src/directives/validators.ts

Overview

      
      @Directive({
    selector: '[email][formControlName],[email][formControl],[email][ngModel]',
    providers: [EMAIL_VALIDATOR]
})
class EmailValidator implements Validator {
  set email: boolean | string
  validate(c: AbstractControl): ValidationErrors | null
  registerOnValidatorChange(fn: () => void): void
}
    

Selectors

      
      [email][formControlName]
[email][formControl]
[email][ngModel]
    

Inputs

Description

A Directive that adds the email validator to controls marked with the email attribute, via the NG_VALIDATORS binding.

Example

      
      <input type="email" name="email" ngModel email>
<input type="email" name="email" ngModel email="true">
<input type="email" name="email" ngModel [email]="true">
    

Members

      
      set email: boolean | string
    

      
      validate(c: AbstractControl): ValidationErrors | null
    

      
      registerOnValidatorChange(fn: () => void): void