When asigning a value to a Schema property with a nested array type the schema appears to mutate the input incorrectly. #8544
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Do you want to request a feature or report a bug?
Report a Bug.
What is the current behavior?
If a variable with the incorrect array nesting is assigned to a schema instance property it mutates the input instead of throwing a validation error.
It feels unhygienic to mutate the schema instance in this way but the resulting behaviour here is unexpected...
If the current behavior is a bug, please provide the steps to reproduce.
See the reproduction here.
https://codesandbox.io/s/sparkling-rain-dbv7v?fontsize=14&hidenavigation=1&theme=dark
The assignment on line 16:
Results in the output:
What is the expected behavior?
An error should be thrown when the incorrect schema object is assigned?
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
node@11.7.0
mongoose@5.8.10
mongodb@4.2
The text was updated successfully, but these errors were encountered: