Angular Validator - EmailRule

A validation rule that demands that the validated field match the Email pattern.

Type:

Object

ignoreEmptyValue

If set to true, empty values are valid.

Type:

Boolean

Default Value: true

message

Specifies the message that is shown if the rule is broken.

Type:

String

Default Value: 'Email is invalid'

An error message can be specified as follows:

  • Hard-code the message

    app.component.html
    app.module.ts
    • <dx-text-box>
    • <dx-validator>
    • <dxi-validation-rule
    • type="email"
    • message="My custom message">
    • </dxi-validation-rule>
    • </dx-validator>
    • </dx-text-box>
    • import { BrowserModule } from '@angular/platform-browser';
    • import { NgModule } from '@angular/core';
    • import { AppComponent } from './app.component';
    •  
    • import { DxValidatorModule,
    • DxTextBoxModule } from 'devextreme-angular';
    •  
    • @NgModule({
    • declarations: [
    • AppComponent
    • ],
    • imports: [
    • DxTextBoxModule,
    • BrowserModule,
    • DxValidatorModule
    • ],
    • providers: [],
    • bootstrap: [AppComponent]
    • })
    • export class AppModule { }
  • Hide the message

    app.component.html
    app.module.ts
    • <dx-text-box>
    • <dx-validator>
    • <dxi-validation-rule
    • type="email"
    • message="">
    • </dxi-validation-rule>
    • </dx-validator>
    • </dx-text-box>
    • import { BrowserModule } from '@angular/platform-browser';
    • import { NgModule } from '@angular/core';
    • import { AppComponent } from './app.component';
    •  
    • import { DxValidatorModule,
    • DxTextBoxModule } from 'devextreme-angular';
    •  
    • @NgModule({
    • declarations: [
    • AppComponent
    • ],
    • imports: [
    • BrowserModule,
    • DxValidatorModule,
    • DxTextBoxModule
    • ],
    • providers: [],
    • bootstrap: [AppComponent]
    • })
    • export class AppModule { }
  • Display the editor's name in the message

    app.component.html
    app.module.ts
    • <dx-text-box>
    • <!-- The error message will be "Mail address is invalid" -->
    • <dx-validator name="Mail address">
    • <dxi-validation-rule
    • type="email">
    • </dxi-validation-rule>
    • </dx-validator>
    • </dx-text-box>
    • import { BrowserModule } from '@angular/platform-browser';
    • import { NgModule } from '@angular/core';
    • import { AppComponent } from './app.component';
    •  
    • import { DxValidatorModule,
    • DxTextBoxModule } from 'devextreme-angular';
    •  
    • @NgModule({
    • declarations: [
    • AppComponent
    • ],
    • imports: [
    • BrowserModule,
    • DxValidatorModule,
    • DxTextBoxModule
    • ],
    • providers: [],
    • bootstrap: [AppComponent]
    • })
    • export class AppModule { }

type

Specifies the rule type. Set it to "email" to use the EmailRule.

Type:

String

Accepted Values: 'required' | 'numeric' | 'range' | 'stringLength' | 'custom' | 'compare' | 'pattern' | 'email' | 'async'