Angular Validator - StringLengthRule
A validation rule that demands the target value length be within the specified value range (including the range's end points).
import { StringLengthRule } from "devextreme/common"
Type:
message
Specifies the message that is shown if the rule is broken.
Type:
Default Value: 'The length of the value is not correct'
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="stringLength"
- 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="stringLength"
- message="">
- </dxi-validator-validation-rule>
- </dx-validator>
- </dx-text-box>
Display the editor's name in the default message (for instance, "The length of the password is not correct"):
app.component.html- <dx-text-box>
- <dx-validator name="password">
- <dxi-validator-validation-rule
- type="stringLength"
- ></dxi-validator-validation-rule>
- </dx-validator>
- </dx-text-box>
trim
Indicates whether or not to remove the Space characters from the validated value.
Type:
Default Value: true
To keep the Space characters within the validated value, set this field to false.