Mongoose 8.x: Required array schema validation breaks in static validation #15164
Closed
2 tasks done
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Prerequisites
Mongoose version
8.9.3
Node.js version
20.17.0
MongoDB server version
7.0.14
Typescript version (if applicable)
5.5.4
Description
When using a schema with a required array field, static validation using
Model.validate()
fails when the array is empty, even though instance validation usingnew Model().validate()
passes.Steps to Reproduce
Run the following code with any 8.x.x version and it will fail the static validation:
Expected Behavior
Both instance validation (
new Model().validate()
) and static validation (Model.validate()
) should pass when the bars array is empty because the array exists and satisfies the required constraint.The text was updated successfully, but these errors were encountered: