diff --git a/js/ui/form/ui.form.layout_manager.js b/js/ui/form/ui.form.layout_manager.js index 369ccbbaf289..977abf7ae20c 100644 --- a/js/ui/form/ui.form.layout_manager.js +++ b/js/ui/form/ui.form.layout_manager.js @@ -727,7 +727,7 @@ var LayoutManager = Widget.inherit({ var fieldName = this._getFieldLabelName(item), validationRules = this._prepareValidationRules(item.validationRules, item.isRequired, item.itemType, fieldName); - if(Array.isArray(validationRules)) { + if(Array.isArray(validationRules) && validationRules.length) { this._createComponent($editor, Validator, { validationRules: validationRules, validationGroup: this.option("validationGroup") diff --git a/js/ui/grid_core/ui.grid_core.editing.js b/js/ui/grid_core/ui.grid_core.editing.js index 18e666c1e142..4096c329a68e 100644 --- a/js/ui/grid_core/ui.grid_core.editing.js +++ b/js/ui/grid_core/ui.grid_core.editing.js @@ -1514,6 +1514,7 @@ var EditingController = modules.ViewController.inherit((function() { } if(item.isRequired === undefined && column.validationRules) { item.isRequired = column.validationRules.some(function(rule) { return rule.type === "required"; }); + item.validationRules = []; } var itemVisible = typeUtils.isDefined(item.visible) ? item.visible : true; diff --git a/testing/tests/DevExpress.ui.widgets.dataGrid/editing.tests.js b/testing/tests/DevExpress.ui.widgets.dataGrid/editing.tests.js index 161c72a0faae..b93dc902c636 100644 --- a/testing/tests/DevExpress.ui.widgets.dataGrid/editing.tests.js +++ b/testing/tests/DevExpress.ui.widgets.dataGrid/editing.tests.js @@ -9369,7 +9369,7 @@ QUnit.test("Required mark should be rendered for column with validationRules whe }, columns: [{ dataField: 'name', - validationRules: [{ type: "required" }] + validationRules: [{ type: "required", message: "Name!" }, { type: "stringLength", max: 20 }] }, { dataField: "lastName", formItem: { @@ -9388,6 +9388,10 @@ QUnit.test("Required mark should be rendered for column with validationRules whe assert.equal($rowElement.find(".dx-validator").length, 2, "validator count"); assert.equal($rowElement.find(".dx-field-item").eq(0).find(".dx-field-item-required-mark").length, 1, "required mark in first item"); assert.equal($rowElement.find(".dx-field-item").eq(1).find(".dx-field-item-required-mark").length, 0, "no required mark in second item"); + var firstValidationRules = $rowElement.find(".dx-validator").eq(0).dxValidator("option", "validationRules"); + assert.equal(firstValidationRules.length, 2, "two validation rules for first column"); // T652579, T651049 + assert.equal(firstValidationRules[0].message, "Name!", "first validation rule has correct message"); // T652602 + assert.equal(firstValidationRules[1].type, "stringLength", "second validation rule type for first column"); // T652579, T651049 }); // T472946