Automattic / Automattic/mongoose
validateSync middleware cycle
- 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
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