Methods

This section describes the methods exposed by the DevExpress.validationEngine namespace.

getGroupConfig()

Provides access to the object that represents the default validation group.

Return Value:

Object

An object representing the requested group.

Use this method to get an object defining the validation group that combines the editors created by the jQuery Approach and for which the validationGroup option is not specified.

The object returned by the getGroupConfig(group) function has the following structure.

  • validators
    An array of Validator widgets that are included to the validated group.
  • validate()
    The method that allows you to validate the widgets included to the current group.
  • validated
    The event that occurs after the group is validated. You can attach/detach a handler using the on(eventName, eventHandler)/off(eventName) methods of the group.

getGroupConfig(group)

Provides access to the object that represents the specified validation group.

Parameters:
group:

String

|

Object

The key of the requested group.

Return Value:

Object

An object representing the requested group.

A validation group's key can be represented in the following manner.

  • A ValidationGroup instance
    If it is not accessible in the current context in code, access it in the following manner.

    JavaScript
    $("#myGroup").dxValidationGroup("instance");
  • A string name
    When you use the jQuery approach for validation, a validation group is usually a string because it is the simplest way to unite several widgets in one group - by setting the same group name for the validationGroup configuration option of the associated dxValidator objects. In this and other similar cases, where you specify a validation group as a string, pass the validation group name as a parameter to the validateGroup(group) function.

The object returned by the getGroupConfig(group) function has the following structure.

  • group
    The string or object passed as the parameter.
  • validators
    An array of Validator widgets that are included to the validated group.
  • validate()
    The method that allows you to validate the widgets included to the current group.
  • validated
    The event that occurs after the group is validated. You can attach/detach a handler using the on(eventName, eventHandler)/off(eventName) methods of the group.

registerModelForValidation(model)

Registers all the Validator objects extending fields of the specified ViewModel.

Parameters:
model:

Object

The ViewModel object has fields extended by the dxValidator objects.

To specify validation rules for ViewModel fields, extend the latter with the dxValidator object.

JavaScript
var viewModel = {
    login: ko.observable("").extend({
        dxValidator: {
            validationRules: [{ type: 'required', message: 'We need your credentials' }]
        }
    }),
    //...
}

To register the rules that are defined within the dxValidator objects, call the DevExpress.validationEngine.registerModelForValidation(model) function passing the ViewModel object as a parameter.

JavaScript
DevExpress.validationEngine.registerModelForValidation(viewModel);

To validate the rules that are defined within the dxValidator objects, call the DevExpress.validationEngine.validateModel(model) function passing the ViewModel object as a parameter.

resetGroup()

Resets the values and validation result of the editors that belong to the default validation group.

Use this method to reset the validation result for the validation group that combines the editors created by the jQuery Approach and for which the validationGroup option is not specified. This method calls the reset method for this group.

resetGroup(group)

Resets the values and validation result of the editors that belong to the specified validation group.

Parameters:
group:

String

|

Object

The key of the requested group.

This method calls the reset method for the specified group.

A validation group's key can be represented in the following manner.

  • A ValidationGroup instance
    If it is not accessible in the current context in code, access it in the following manner.

    JavaScript
    $("#myGroup").dxValidationGroup("instance")
  • A string name
    When you use the jQuery approach for validation, a validation group is usually a string because it is the simplest way to unite several widgets in one group - by setting the same group name for the validationGroup configuration option of the associated dxValidator objects. In this and other similar cases, where you specify a validation group as a string, pass the validation group name as a parameter to the validateGroup(group) function.

unregisterModelForValidation(model)

Unregisters all the Validator objects extending fields of the specified ViewModel.

Parameters:
model:

Object

Specifies the model to unregister.

validateGroup()

Validates rules of the validators that belong to the default validation group.

Return Value:

Object

An object defining the result of validating the default group.

Use this method to validate the editors from the default validation group that combines the editors created by the jQuery Approach and for which the validationGroup option is not specified.

The object returned by the validateGroup(group) function has the following structure.

  • isValid
    Indicates whether or not all the rules checked for the specified group are satisfied.

  • brokenRules
    An array of broken rules. The structure of rule objects is described in the validation Rules section.

  • validators
    An array of Validator widgets that are included to the validated group.

To validate editors belonging to the default validation group and created using the Knockout Approach, call the validateGroup(group) method passing the view model as a parameter.

To validate editors belonging to the default validation group that are also created using the AngularJS Approach, call the validateGroup(group) method passing the $scope object as a parameter.

Show Example:
AngularJS
Knockout
jQuery

validateGroup(group)

Validates rules of the validators that belong to the specified validation group.

Parameters:
group:

String

|

Object

The key of the group to be validated.

Return Value:

Object

An object defining the result of validating the specified group.

A validation group's key can be represented in the following manner.

  • A ValidationGroup instance
    If it is not accessible in the current context in code, access it in the following manner.

    JavaScript
    $("#myGroup").dxValidationGroup("instance")
  • A string name
    When you use the jQuery approach for validation, a validation group is usually a string because it is the simplest way to unite several widgets in one group - by setting the same group name for the validationGroup configuration option of the associated dxValidator objects. In this and other similar cases, where you specify a validation group as a string, pass the validation group name as a parameter to the validateGroup(group) function.

The object returned by the validateGroup(group) function has the following structure.

  • isValid
    Indicates whether or not all the rules checked for the specified group are satisfied.

  • brokenRules
    An array of broken rules. The structure of rule objects is described in the validation Rules section.

  • validators
    An array of Validator widgets that are included to the validated group.

Show Example:
AngularJS
Knockout
jQuery

validateModel(model)

Validates the rules that are defined within the dxValidator objects that are registered for the specified ViewModel.

Parameters:
model:

Object

The ViewModel object that has fields extended by the dxValidator objects.

Return Value:

Object

An object defining the result of validating the specified ViewModel.

To specify validation rules for ViewModel fields, extend the latter with the dxValidator object.

JavaScript
var viewModel = {
    login: ko.observable("").extend({
        dxValidator: {
            validationRules: [{ type: 'required', message: 'We need your credentials' }]
        }
    }),
    //...
}

To register the rules that are defined within the dxValidator objects, call the DevExpress.validationEngine.registerModelForValidation(model) function passing the ViewModel object as a parameter.

JavaScript
DevExpress.validationEngine.registerModelForValidation(viewModel);

To validate the rules that are defined within the dxValidator objects, call the DevExpress.validationEngine.validateModel(model) function passing the ViewModel object as a parameter.

JavaScript
DevExpress.validationEngine.registerModelForValidation(viewModel);

The object returned by this function has the following structure.

  • isValid
    Indicates whether all the rules checked for the specified ViewModel are satisfied.
  • brokenRules
    An array of broken rules. The structure of rule objects is described in the validation Rules section.
  • validators
    An array of Validator widgets that are included to the validated ViewModel.