jQuery/JS Common - Utils - validationEngine
getGroupConfig()
The object returned by the getGroupConfig(group) function has the following structure.
- validators
An array of Validator UI components that are included to the validated group. - validate()
The method that allows you to validate the UI components 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.
jQuery
let defaultValidationGroup = DevExpress.validationEngine.getGroupConfig(); // ===== or when using modules ===== import validationEngine from 'devextreme/ui/validation_engine'; let defaultValidationGroup = validationEngine.getGroupConfig();
Angular
import validationEngine from 'devextreme/ui/validation_engine'; let defaultValidationGroup = validationEngine.getGroupConfig();
Vue
import validationEngine from 'devextreme/ui/validation_engine'; let defaultValidationGroup = validationEngine.getGroupConfig();
React
import validationEngine from 'devextreme/ui/validation_engine'; let defaultValidationGroup = validationEngine.getGroupConfig();
getGroupConfig(group)
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 UI components that are included to the validated group. - validate()
The method that allows you to validate the UI components 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.
jQuery
let validationGroup = DevExpress.validationEngine.getGroupConfig('myGroup'); // ===== or when using modules ===== import validationEngine from 'devextreme/ui/validation_engine'; let validationGroup = validationEngine.getGroupConfig('myGroup');
Angular
import validationEngine from 'devextreme/ui/validation_engine'; let validationGroup = validationEngine.getGroupConfig('myGroup');
Vue
import validationEngine from 'devextreme/ui/validation_engine'; let validationGroup = validationEngine.getGroupConfig('myGroup');
React
import validationEngine from 'devextreme/ui/validation_engine'; let validationGroup = validationEngine.getGroupConfig('myGroup');
registerModelForValidation(model)
Registers all the Validator objects extending fields of the specified ViewModel.
To specify validation rules for ViewModel fields, extend the latter with the dxValidator object.
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.
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()
jQuery
DevExpress.validationEngine.resetGroup(); // ===== or when using modules ===== import validationEngine from 'devextreme/ui/validation_engine'; validationEngine.resetGroup();
Angular
import validationEngine from 'devextreme/ui/validation_engine'; validationEngine.resetGroup();
Vue
import validationEngine from 'devextreme/ui/validation_engine'; validationEngine.resetGroup();
React
import validationEngine from 'devextreme/ui/validation_engine'; validationEngine.resetGroup();
resetGroup(group)
Resets the values and validation result of the editors that belong to the specified validation group.
jQuery
DevExpress.validationEngine.resetGroup('myGroup'); // ===== or when using modules ===== import validationEngine from 'devextreme/ui/validation_engine'; validationEngine.resetGroup('myGroup');
Angular
import validationEngine from 'devextreme/ui/validation_engine'; validationEngine.resetGroup('myGroup');
Vue
import validationEngine from 'devextreme/ui/validation_engine'; validationEngine.resetGroup('myGroup');
React
import validationEngine from 'devextreme/ui/validation_engine'; validationEngine.resetGroup('myGroup');
unregisterModelForValidation(model)
Unregisters all the Validator objects extending fields of the specified ViewModel.
validateGroup()
jQuery
let validationResult = DevExpress.validationEngine.validateGroup(); // ===== or when using modules ===== import validationEngine from 'devextreme/ui/validation_engine'; let validationResult = validationEngine.validateGroup();
Angular
import validationEngine from 'devextreme/ui/validation_engine'; let validationResult = validationEngine.validateGroup();
Vue
import validationEngine from 'devextreme/ui/validation_engine'; let validationResult = validationEngine.validateGroup();
React
import validationEngine from 'devextreme/ui/validation_engine'; let validationResult = validationEngine.validateGroup();
See Also
validateModel(model)
The validation result.
To specify validation rules for ViewModel fields, extend the latter with the dxValidator object.
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.
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.
DevExpress.validationEngine.registerModelForValidation(viewModel);