validateSync middleware cycle
Author: AbdelrahmanHafezCreated May 21, 2026Updated May 30, 2026
Labelsbackwards-breaking
Is this intended or a bug?
schema.pre('validate', () => ++pre);
schema.post('validate', () => ++post);
doc.validateSync(); // pre/post stay 0
await doc.validate(); // pre/post rundoc.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
Source: Automattic/mongoose