Vue 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
Type:
Default Value: 'The length of the value is not correct'
An error message can be specified as follows:
Hard-code the message
App.vue- <template>
- <DxTextBox>
- <DxValidator>
- <DxStringLengthRule
- message="My custom message"
- />
- </DxValidator>
- </DxTextBox>
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import { DxTextBox } from 'devextreme-vue/text-box';
- import {
- DxValidator,
- DxStringLengthRule
- } from 'devextreme-vue/validator';
- export default {
- components: {
- DxTextBox,
- DxValidator,
- DxStringLengthRule
- }
- }
- </script>
Hide the message
App.vue- <template>
- <DxTextBox>
- <DxValidator>
- <DxStringLengthRule
- message=""
- />
- </DxValidator>
- </DxTextBox>
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import { DxTextBox } from 'devextreme-vue/text-box';
- import {
- DxValidator,
- DxStringLengthRule
- } from 'devextreme-vue/validator';
- export default {
- components: {
- DxTextBox,
- DxValidator,
- DxStringLengthRule
- }
- }
- </script>
Display the editor's name in the message
App.vue- <template>
- <DxTextBox>
- <!-- The error message will be "The length of the password is not correct" -->
- <DxValidator name="password">
- <DxStringLengthRule />
- </DxValidator>
- </DxTextBox>
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import { DxTextBox } from 'devextreme-vue/text-box';
- import {
- DxValidator,
- DxStringLengthRule
- } from 'devextreme-vue/validator';
- export default {
- components: {
- DxValidator,
- DxStringLengthRule
- }
- }
- </script>
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.