Vue Validator - PatternRule
import { PatternRule } from "devextreme/common"
Type:
To specify the regular expression that the validated field must match, set the rule's pattern configuration property.
NOTE
If you apply a pattern rule to a DateBox component, specify dateSerializationFormat so that the format of the validated value is a string.
See Also
message
Type:
Default Value: 'Value does not match pattern'
An error message can be specified as follows:
Hard-code the message
App.vue- <template>
- <DxTextBox>
- <DxValidator>
- <DxPatternRule
- message="My custom message"
- />
- </DxValidator>
- </DxTextBox>
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import { DxTextBox } from 'devextreme-vue/text-box';
- import {
- DxValidator,
- DxPatternRule
- } from 'devextreme-vue/validator';
- export default {
- components: {
- DxTextBox,
- DxValidator,
- DxPatternRule
- }
- }
- </script>
Hide the message
App.vue- <template>
- <DxTextBox>
- <DxValidator>
- <DxPatternRule
- message=""
- />
- </DxValidator>
- </DxTextBox>
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import { DxTextBox } from 'devextreme-vue/text-box';
- import {
- DxValidator,
- DxPatternRule
- } from 'devextreme-vue/validator';
- export default {
- components: {
- DxTextBox,
- DxValidator,
- DxPatternRule
- }
- }
- </script>
Display the editor's name in the message
App.vue- <template>
- <DxTextBox>
- <!-- The error message will be "Phone number does not match pattern" -->
- <DxValidator name="Phone number">
- <DxPatternRule />
- </DxValidator>
- </DxTextBox>
- </template>
- <script>
- import 'devextreme/dist/css/dx.light.css';
- import { DxTextBox } from 'devextreme-vue/text-box';
- import {
- DxValidator,
- DxPatternRule
- } from 'devextreme-vue/validator';
- export default {
- components: {
- DxValidator,
- DxPatternRule
- }
- }
- </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.