Skip to content

Grids: move _validatingController definition from base dataController - #34761

Merged
bit-byte0 merged 6 commits into
DevExpress:mainfrom
bit-byte0:refactor/gridcore-relocate-validating-controller-26_2
Aug 14, 2026
Merged

Grids: move _validatingController definition from base dataController#34761
bit-byte0 merged 6 commits into
DevExpress:mainfrom
bit-byte0:refactor/gridcore-relocate-validating-controller-26_2

Conversation

@bit-byte0

@bit-byte0 bit-byte0 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What

Relocated the _validatingController reference from the base DataController to the validating data-controller extender

How

Moved the field and its lookup into a new init() on the extender, extracted the extender and module into their own files, narrowed the reference to a read-only port, and added a public getValidationData accessor so the extender no longer reaches a private method

@bit-byte0 bit-byte0 added the 26_2 label Aug 13, 2026
@bit-byte0
bit-byte0 requested a review from a team as a code owner August 13, 2026 09:39
Copilot AI lite review requested due to automatic review settings August 13, 2026 09:39
@bit-byte0 bit-byte0 added the 26_2 label Aug 13, 2026
@bit-byte0 bit-byte0 self-assigned this Aug 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the grids validating feature so _validatingController is no longer a base DataController concern, and is instead initialized only by the validating data-controller extender that actually uses it. This keeps the base controller slimmer and reduces unnecessary coupling between core data logic and the validating module.

Changes:

  • Removed _validatingController field initialization from DataController and moved it into the validating DataController extender’s init().
  • Extracted validating module wiring and validating data-controller extender into dedicated files.
  • Introduced shared validating constants and a ValidatingController.getValidationData() accessor to avoid extender access to a private method.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/devextreme/js/__internal/grids/tree_list/m_validating.ts Switches TreeList validating module import to the new validating_module entry.
packages/devextreme/js/__internal/grids/grid_core/validating/validating_module.ts New module entry point composing controllers/extenders for validating.
packages/devextreme/js/__internal/grids/grid_core/validating/m_validating.ts Removes inline module/extender exports that were extracted; adds shared const import; adds getValidationData.
packages/devextreme/js/__internal/grids/grid_core/validating/extenders/validating_data_controller.ts New validating data-controller extender with localized _validatingController initialization and updated access via getValidationData.
packages/devextreme/js/__internal/grids/grid_core/validating/const.ts New shared constants/utilities extracted from m_validating.
packages/devextreme/js/__internal/grids/grid_core/data_controller/data_controller.ts Removes validating controller field and lookup from the base data controller.
packages/devextreme/js/__internal/grids/data_grid/module_not_extended/validating.ts Switches DataGrid validating module import to the new validating_module entry.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bit-byte0
bit-byte0 force-pushed the refactor/gridcore-relocate-validating-controller-26_2 branch from f26a9fc to 91bbd4d Compare August 13, 2026 10:37
Copilot AI review requested due to automatic review settings August 13, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Suppressed comments (2)

packages/devextreme/js/__internal/grids/grid_core/validating/extenders/validating_data_controller.ts:58

  • Calling the base implementation with explicit parameters is inconsistent with other _isCellChanged overrides in the codebase (they delegate via apply(this, arguments as any)), and it can become incorrect if the base method signature gains additional parameters. For reference, see grid_core/editing/m_editing.ts:2632 and tree_list/data_controller/m_data_controller.ts:67.
    return super._isCellChanged(oldRow, newRow, visibleRowIndex, columnIndex, isLiveUpdate);

packages/devextreme/js/__internal/grids/grid_core/validating/extenders/validating_data_controller.ts:33

  • _getValidationStatus currently relies on an eslint suppression (no-unsafe-return) because validationStatus is inferred as any. This can be avoided by typing the parameter and casting the derived status to string, which keeps the intent clear without disabling lint rules.
  private _getValidationStatus(validationResult): string {
    const validationStatus = validationResultIsValid(validationResult)
      ? validationResult.status
      : validationResult;

    // eslint-disable-next-line @typescript-eslint/no-unsafe-return
    return validationStatus ?? VALIDATION_STATUS.valid;
  }

} from './m_validating';

export const validatingModule = {
defaultOptions(): { editing: { texts: { validationCancelChanges: string } } } {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets create type for it, we also may use public types, smth like
type ValidationOptions = { editing: { texts: Pick<EditingTextsBase, 'validationCancelChanges'> } };

super.init();
}

private _getValidationStatus(validationResult): string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets try type this method

return validationStatus ?? VALIDATION_STATUS.valid;
}

protected _isCellChanged(oldRow, newRow, visibleRowIndex, columnIndex, isLiveUpdate): boolean {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebase and type the method, please

Copilot AI review requested due to automatic review settings August 13, 2026 11:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


export const VALIDATION_CANCELLED = 'cancel';

export const validationResultIsValid = (result: unknown): boolean => isDefined(result)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make it type guard

Suggested change
export const validationResultIsValid = (result: unknown): boolean => isDefined(result)
export const validationResultIsValid = (result: unknown): result is CellValidationResult => isDefined(result)

valid: 'valid',
invalid: 'invalid',
pending: 'pending',
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
};
} as const;
export type ValidationStatus = typeof VALIDATION_STATUS[keyof typeof VALIDATION_STATUS];

} from '../const';

interface CellValidationResult {
status?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
status?: string;
status?: ValidationStatus;
  • move to upper level, where guard and ValidationStatus live

Copilot AI review requested due to automatic review settings August 13, 2026 21:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Suppressed comments (3)

packages/devextreme/js/__internal/grids/grid_core/validating/extenders/validating_data_controller.ts:22

  • cellOptions.validationStatus can be set to VALIDATION_CANCELLED (see validating controller logic), so ValidatedCell.validationStatus should include that sentinel. Otherwise the typing here is narrower than the runtime values and can hide errors when refactoring.
type ValidatedCell = Cell & {
  validationStatus?: ValidationStatus;
  cellElement?: Element;
};

packages/devextreme/js/__internal/grids/grid_core/validating/extenders/validating_data_controller.ts:13

  • ValidationResult is typed as CellValidationResult | string | undefined, but getCellValidationResult() appears to store either a result object or the VALIDATION_CANCELLED sentinel. Keeping this as a broad string makes validationResultIsValid() a potentially unsafe type guard (any non-"cancel" string would be treated as an object). Consider narrowing the string case to typeof VALIDATION_CANCELLED.

This issue also appears on line 19 of the same file.

type ValidationResult = CellValidationResult | string | undefined;

packages/devextreme/js/__internal/grids/grid_core/validating/const.ts:22

  • validationResultIsValid is declared as a type guard for CellValidationResult, but the current implementation returns true for any defined non-VALIDATION_CANCELLED value (including primitives). Tightening it to require an object keeps the type guard accurate and prevents accidental mis-narrowing if other sentinel strings ever appear.
export const validationResultIsValid = (
  result: unknown,
): result is CellValidationResult => isDefined(result) && result !== VALIDATION_CANCELLED;

@bit-byte0
bit-byte0 added this pull request to the merge queue Aug 14, 2026
Merged via the queue into DevExpress:main with commit 8251620 Aug 14, 2026
101 checks passed
@bit-byte0
bit-byte0 deleted the refactor/gridcore-relocate-validating-controller-26_2 branch August 14, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants