Angular Validator - EmailRule
A validation rule that requires that the validated field match the Email pattern.
import { EmailRule } from "devextreme/common"
Type:
DevExtreme components use the following Email pattern:
Code
- pattern: /^[\d\w._-]+@[\d\w._-]+\.[\w]+$/i
See Also
message
Specifies the message that is shown if the rule is broken.
Type:
Default Value: 'Email is invalid'
You can configure an error message in the following ways:
Specify a hard-coded message:
app.component.htmlapp.module.ts- <dx-text-box>
- <dx-validator>
- <dxi-validator-validation-rule
- type="email"
- message="My custom message">
- </dxi-validator-validation-rule>
- </dx-validator>
- </dx-text-box>
- import { DxValidatorModule, DxTextBoxModule } from 'devextreme-angular';
- // ...
- @NgModule({
- imports: [
- DxTextBoxModule,
- DxValidatorModule,
- ],
- })
Hide the message:
app.component.html- <dx-text-box>
- <dx-validator>
- <dxi-validator-validation-rule
- type="email"
- message="">
- </dxi-validator-validation-rule>
- </dx-validator>
- </dx-text-box>
Display the editor's name in the default message (for instance, "Mail address is invalid"):
app.component.html- <dx-text-box>
- <dx-validator name="Mail address">
- <dxi-validator-validation-rule
- type="email"
- ></dxi-validator-validation-rule>
- </dx-validator>
- </dx-text-box>