-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Subdocument schema not propagating validate error #7187
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
Even with the old
output:
|
ivanseidel
changed the title
Subdocument schema not propagating validate and save errors
Subdocument schema not propagating validate error
Oct 28, 2018
vkarpov15
added
the
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
label
Oct 31, 2018
Thanks for reporting, will fix asap 👍 |
Perfect! thanks |
I am seeing this same issue when updating a schema. Possibly a bug? |
vkarpov15
added
needs repro script
Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue
and removed
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
labels
Oct 7, 2019
@bopfer we don't run pre('validate') hooks on query validation currently. We've made some improvements on that front and we'll fix this issue, but for now, as a workaround, define a custom validator on the const addressSchema = new mongoose.Schema({
address: String,
city: String,
regionId: String,
postalCode: String,
countryId: { type: String, validate: () => { throw new Error('fail'); } }
}); |
vkarpov15
added
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
and removed
needs repro script
Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue
labels
Oct 11, 2019
This was referenced Mar 11, 2021
Open
This was referenced Mar 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following code uses a subschema that produces errors during validate. If that same code is placed in the root document, it fails, but all subschemas does not prevent saving or validating.
The following code should have prevented saving, but succeeded:
output:
The text was updated successfully, but these errors were encountered: