-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mongoose 8.x: Discriminator schema validation breaks in static validation #15075
Closed
2 tasks done
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
vkarpov15
added a commit
that referenced
this issue
Dec 16, 2024
fix(model): handle discriminators in castObject()
Fixed by #15096 |
@vkarpov15 I am still experiencing inconsistency between static and instance validation. If I modify the test case to change const square = { shape: [{ kind: 'Square', propertyPaths: {} }] }; Here are the results:
The static validation is still incorrectly passing in this case. |
vkarpov15
added a commit
that referenced
this issue
Dec 22, 2024
fix(model): handle document array paths set to non-array values in Model.castObject()
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
8.8.3 (also observed in 8.0.0)
Node.js version
20.17.0
MongoDB server version
7.0.15
Typescript version (if applicable)
No response
Description
There are significant inconsistencies in validation behavior between instance validation (
new Model().validate()
) and static validation (Model.validate()
) when using discriminator schemas with nested document arrays:Instance Validation
Static Validation
Regression?
This issue appears to have changed in behavior between Mongoose versions:
Steps to Reproduce
Expected Behavior
Both
new Model().validate()
andModel.validate()
should:propertyPaths
propertiesThe text was updated successfully, but these errors were encountered: