• Overview
@angular/forms

EmailValidator

directive

A directive that adds the email validator to controls marked with the email attribute. The directive is provided with the NG_VALIDATORS multi-provider list.

API

  
    class EmailValidator extends AbstractValidatorDirective {}
  
  

email

string | boolean

Tracks changes to the email attribute bound to this directive.

enabled

boolean
@paraminputboolean
@returnsboolean

ngOnChanges

void
@paramchangesSimpleChanges
@returnsvoid

validate

ValidationErrors | null
@paramcontrolAbstractControl<any, any>
@returnsValidationErrors | null

registerOnValidatorChange

void
@paramfn() => void
@returnsvoid

Description

A directive that adds the email validator to controls marked with the email attribute. The directive is provided with the NG_VALIDATORS multi-provider list.

The email validation is based on the WHATWG HTML specification with some enhancements to incorporate more RFC rules. More information can be found on the Validators.email page.


Exported by

Usage Notes

Adding an email validator

The following example shows how to add an email validator to an input attached to an ngModel binding.

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