jQuery/JS Common - utils - validationEngine - Methods

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

getGroupConfig()

Gets the default validation group.

Return Value:

Object

The default validation 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)

Gets a validation group with a specific key.

Parameters:
group:

String

|

Object

The validation group's key.

Return Value:

Object

The validation 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 validation group's key.

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 editors from the default validation group.

Return Value:

dxValidationGroupResult

The validation result.

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.

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.

See Also

validateGroup(group)

Validates editors from a specific validation group.

Parameters:
group:

String

|

Object

The validation group's key.

Return Value:

dxValidationGroupResult

The validation result.

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.

See Also

validateModel(model)

Validates a view model.

Parameters:
model:

Object

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

Return Value:

Object

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);