Automattic / Automattic/mongoose

validateSync middleware cycle

Open
#16,291 2 comments 1 reaction 0 assignees View on GitHub
backwards-breaking
Dominant language
JavaScript
Stars
27.5k
Forks
4k
Avg merge
2d 7h
Merged PRs (30d)
35

Description

Is this intended or a bug?
```js
schema.pre('validate', () => ++pre);
schema.post('validate', () => ++post);

doc.validateSync(); // pre/post stay 0
await doc.validate(); // pre/post run
```

`doc.validateSync()` has a `middleware: false` option added in #15883 , but there's not validateSync middleware cycle at all right now.
I should either remove the option from the docs/TS, or add a validateSync synchronous middleware akin to `init`.

Thoughts? @vkarpov15 @hasezoey

Contributor guide

Open the contributing guide

Research direction

Start with the doc.validateSync() entry point and its middleware: false option, then compare the existing async validate() path with the synchronous init middleware mentioned in the issue. Check the documentation and TypeScript definitions referenced in the issue; done means the chosen validateSync middleware behavior is implemented consistently or the option is removed from both places.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb
Domain
backend, databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.