Configuration

An object defining configuration options for the Validator widget.

adapter

An object that specifies what and when to validate, and how to apply the validation result.

Type: Object

This option should be specified when you cannot associate the Validator widget with an editor, for instance, when you use custom editors or a validated value is a sequence of several DevExtreme editor values. Refer to the Validate a Custom Value topic for more details.

See Also

elementAttr

Specifies the attributes to be attached to the widget's root element.

Type: Object
Default Value: {}

height

Specifies the widget's height.

Return Value: Number|String

The widget height.

Default Value: undefined

This option accepts a value of one of the following types.

  • Number
    The height of the widget in pixels.

  • String
    A CSS-accepted measurement of height. For example, "55px", "80%", "auto", "inherit".

  • Function
    A function returning either of the above. For example:

    JavaScript
    height: function() {
        return window.innerHeight / 1.5;
    }

name

Specifies the editor name to be used in the validation default messages.

Type: String

All predefined rules have a default message displayed when the rules are not satisfied by the validated editor values. If you specify the name option of the associated dxValidator object, the option value will be used as an object in the default message. For instance, the "Value is invalid" message will be transformed to "Login is invalid", if you set "Login" for the name option.

onDisposing

A handler for the disposing event. Executed when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only.

Type: function
Function parameters:

Information about the event.

Object structure:
component: Object
element: jQuery

The widget's container.

model: Object

The model data. Available only if you use Knockout.

Default Value: null

onInitialized

A handler for the initialized event. Executed only once, after the widget is initialized.

Type: function
Function parameters:

Information about the event.

Object structure:
component: Object
element: jQuery

The widget's container.

Default Value: null

You cannot access elements in the widget because this handler is executed before they are ready. Use the onContentReady handler instead.

onOptionChanged

A handler for the optionChanged event. Executed after an option of the widget is changed.

Type: function
Function parameters:

Information about the event.

Object structure:
component: Object
name: String

A short name of the option whose value has been changed.

fullName: String

A full name of the option whose value has been changed; contains a full hierarchy of the option.

value: any

A new value for the option.

element: jQuery

The widget's container.

model: Object

The model data. Available only if you use Knockout.

Default Value: null

onValidated

A handler for the validated event.

Type: Date
Function parameters:
validatedInfo: Object

Provides function parameters.

Object structure:
name: String

The value of the name option.

isValid: Boolean

Indicates whether all the rules checked for the value are satisfied.

value: Object

The validated value.

validationRules: Array

An array of validation rules specified for the current dxValidator object.

brokenRule: Object

The object representing the first broken rule on the list of specified validation rules.

Assign a function to perform a custom action after an editor value is validated against the specified validation rules.

validationGroup

Specifies the validation group the editor will be related to.

Type: String

Generally, the editors that are associated with dxValidator objects are validated on each value change. But you can combine several editors into a group so that they are validated together (e.g., on a button click). In the Knockout or AngularJS approach, editors should be added to the div element representing the ValidationGroup component. In this instance, you do not have to specify the validationGroup option for the associated dxValidator objects.

If you use the JQuery approach, the validationGroup option should be specified for the associated dxValidator object to indicate the validation group within which the editor will be validated. Assign the same validation group name for those editors that should be validated together.

See Also

validationRules

An array of validation rules to be checked for the editor with which the dxValidator object is associated.

Type: Array

There are several predefined rule types. Each rule type demands a specific set of rule options. Use the Validation Rules section to learn how to define rules of different types.

width

Specifies the widget's width.

Return Value: Number|String

The widget width.

Default Value: undefined

This option accepts a value of one of the following types.

  • Number
    The width of the widget in pixels.

  • String
    A CSS-accepted measurement of width. For example, "55px", "80%", "auto", "inherit".

  • Function
    A function returning either of the above. For example:

    JavaScript
    width: function() {
        return window.innerWidth / 1.5;
    }