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
Type:
Default Value: 'The length of the value is not correct'
An error message can be specified as follows:
Hard-code the message
App.js- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import { TextBox } from 'devextreme-react/text-box';
- import {
- Validator,
- StringLengthRule
- } from 'devextreme-react/validator';
- class App extends React.Component {
- render() {
- return (
- <TextBox>
- <Validator>
- <StringLengthRule
- message="My custom message" />
- </Validator>
- </TextBox>
- );
- }
- }
- export default App;
Hide the message
App.js- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import { TextBox } from 'devextreme-react/text-box';
- import {
- Validator,
- StringLengthRule
- } from 'devextreme-react/validator';
- class App extends React.Component {
- render() {
- return (
- <TextBox>
- <Validator>
- <StringLengthRule
- message="" />
- </Validator>
- </TextBox>
- );
- }
- }
- export default App;
Display the editor's name in the message
App.js- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import { TextBox } from 'devextreme-react/text-box';
- import {
- Validator,
- StringLengthRule
- } from 'devextreme-react/validator';
- class App extends React.Component {
- render() {
- return (
- <TextBox>
- {/* The error message will be "The length of the password is not correct" */}
- <Validator name="password">
- <StringLengthRule} />
- </Validator>
- </TextBox>
- );
- }
- }
- export default App;
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.