Angular Validator - NumericRule
A validation rule that demands that the validated field has a numeric value.
import { NumericRule } from "devextreme/common"
Type:
message
Specifies the message that is shown if the rule is broken.
Type:
Default Value: 'Value should be a number'
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="numeric"
- 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="numeric"
- message="">
- </dxi-validator-validation-rule>
- </dx-validator>
- </dx-text-box>
Display the editor's name in the default message (for instance, "Age should be a number"):
app.component.html- <dx-text-box>
- <dx-validator name="Age">
- <dxi-validator-validation-rule
- type="numeric"
- ></dxi-validator-validation-rule>
- </dx-validator>
- </dx-text-box>