React Validator - StringLengthRule

A validation rule that demands the target value length be within the specified value range (including the range's end points).

Type:

Object

To specify the range that the validated value length must match, set the rule's min and max configuration options.

NOTE
This rule validates string values or the values that can be cast to a string.

View Demo

See Also

max

Specifies the maximum length allowed for the validated value.

Type:

Number

message

Specifies the message that is shown for end-users if the current rule is broken.

Type:

String

Default Value: 'The length of the value is not correct'

You do not have to specify this field. If you choose not to specify it, a default message will be shown. To include the name of the validated editor into the default validation message as a subject, set the name field of the dxValidator object.

If you assign an empty string to the message field, the message will not be shown.

min

Specifies the minimum length allowed for the validated value.

Type:

Number

trim

Indicates whether or not to remove the Space characters from the validated value.

Type:

Boolean

Default Value: true

To keep the Space characters within the validated value, set this field to false.

type

Specifies the type of the current rule.

Type:

String

Accepted Values: 'required' | 'numeric' | 'range' | 'stringLength' | 'custom' | 'compare' | 'pattern' | 'email'

Set this field to 'stringLength' to define a rule that will be broken if the validated value length does not match to the range specified by the min and max configuration options.