How to walk through a schema's paths, recursing on subdocuments and arrays? #13469
Closed
1 task done
Labels
help wanted
help
This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
Prerequisites
Mongoose version
6.8.4
Node.js version
18.12.0
MongoDB version
6
Operating system
None
Operating system version (i.e. 20.04, 11.3, 10)
No response
Issue
I want to write a test ensuring that if a schema path is an optional enum, then
null
is included as an allowed value. (That Mongoose doesn't automatically includenull
for optional enums arguably a design flaw, but that's another topic.)I've written this code which works for scalar fields:
But I can't figure out how to recursively handle subdocuments and arrays. I spent an hour trying to figure it out, but there are too many undocumented methods in the API. Any help would be much appreciated. Thanks!
The text was updated successfully, but these errors were encountered: