Skip to content

fix(document): deprecate validateSync re #16291 - #16310

Merged
vkarpov15 merged 3 commits into
masterfrom
fix/deprecate-validate-sync
May 30, 2026
Merged

fix(document): deprecate validateSync re #16291#16310
vkarpov15 merged 3 commits into
masterfrom
fix/deprecate-validate-sync

Conversation

@AbdelrahmanHafez

Copy link
Copy Markdown
Collaborator

re #16291
This PR:

  • removes middleware support from the validateSync() TypeScript surface, because validateSync() does not run validate middleware
  • marks Document.prototype.validateSync() as deprecated in the runtime JSDoc and TypeScript declarations
  • emits a deprecation warning when validateSync() is called
  • updates the deprecation docs and focused type/runtime coverage

Runtime validation behavior is otherwise unchanged.

@AbdelrahmanHafez
AbdelrahmanHafez marked this pull request as ready for review May 28, 2026 23:51
@AbdelrahmanHafez
AbdelrahmanHafez requested a review from Copilot May 28, 2026 23:52

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

This PR deprecates Document.prototype.validateSync() across runtime, TypeScript types, and docs to reflect that validateSync() does not run validation middleware, and removes middleware options from the validateSync() TypeScript surface.

Changes:

  • Deprecates Document#validateSync() in JSDoc and TypeScript declarations, and emits a runtime warning when validateSync() is called.
  • Introduces an internal Document#$__validateSync() entry point and updates internal validators (subdocs, document arrays, unions, bulkSave) to use it to avoid cascading warnings.
  • Updates deprecations documentation and adds focused runtime/type coverage around the new deprecation behavior.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
types/document.d.ts Adds ValidateSyncOptions (excluding middleware) and marks validateSync() overloads as deprecated.
test/types/model.skip.middleware.test.ts Updates type tests to assert validateSync() rejects middleware options.
test/document.test.js Adds runtime tests for the new validateSync() deprecation warning behavior, including bulkSave and nested validation.
lib/schema/union.js Preferentially calls $__validateSync() to avoid repeated deprecation warnings for union values.
lib/schema/subdocument.js Switches subdocument sync validation to $__validateSync().
lib/schema/documentArray.js Switches document array sync validation to $__validateSync(options).
lib/model.js Uses $__validateSync() during bulk write operation building to avoid user-facing warnings.
lib/document.js Deprecates validateSync() with warning wrapper and moves prior logic to $__validateSync().
docs/deprecations.md Documents the validateSync() deprecation and behavioral notes (no middleware + skips async validators).

Comment thread lib/document.js

@vkarpov15 vkarpov15 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One minor comment but looks good overall

Comment thread lib/schema/union.js Outdated

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 8 out of 9 changed files in this pull request and generated 1 comment.

Comment thread lib/document.js
@vkarpov15 vkarpov15 added this to the 9.7 milestone May 30, 2026
@vkarpov15
vkarpov15 merged commit 1244558 into master May 30, 2026
77 of 79 checks passed
@vkarpov15
vkarpov15 deleted the fix/deprecate-validate-sync branch May 30, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants