-
-
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
Skip validation for certain path(s) in Document.validate() method #10216
Comments
Any updates @mongoose team? |
Thats not how $markModified works according to the docs |
@IslandRhythms Please read my issue again I am talking about $markValid not $markModified. Also $markModified is not any function, it's markModified |
There is a discrepancy between the steps you list to reproduce the issue and the image you have provided. You are using $markModified in the steps but $markValid in the image. Please clear that up. |
@IslandRhythms Done, and apologies for that. Could you now look into this issue? |
|
@IslandRhythms Is there any changelog for each mongoose release? |
@tbhaxor yes, here's the link: https://github.com/Automattic/mongoose/blob/master/History.md |
Currently this is by design, because You should be able to set the const entry = new Test({nickname: 'Test'});
await entry.validate({ validateModifiedOnly: true }); The above won't quite work, we'll need to support passing options as the first parameter to |
…options` as first parameter Re: #10216
@vkarpov15 Also I have seen mongoose doesn't sanitize queries and executes malicious payloads. I have explained in this article If you guys will help me in understanding file structure and repo (contribution guide for developers), then may be I can open few Pull requests for opened issues |
I'm currently working on a series of blog posts about that very subject :) First one is here: http://thecodebarbarian.com/mongoose-internals-schemas-options-models.html . Re: sanitizing query filters, we're working on that for Mongoose 6.0. Follow #3944 for updates. |
Nice blog, @vkarpov15 . I need more posts to be confident about sending quality PR's to the repo. How can I subscribe to the blog? |
RSS: http://thecodebarbarian.com/feed.xml, or my Twitter: https://twitter.com/code_barbarian . There's only one post so far, so I would recommend tinkering with the code and starting with a small bug or feature if you want to contribute. One good place to start would be #10230, which is closely related to the problem you're trying to solve with this issue and should be about the right level of complexity for a first contribution. |
I'm going to close this issue for now, we made a workaround for 5.12.9, and #10230 will give us a better approach for 5.13. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Unable to skip or prevalidate or bypass the validation for a path on mongoose
If the current behavior is a bug, please provide the steps to reproduce.
doc.validate(["path"]).catch(e => console.log(Object.keys(e.errors).length))
Here I want to bypass the
required
validation for gwId fieldWhat is the expected behaviour?
Well, $markValid should bypass all the validators for one or more paths (except unique)
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Mongoose: 5.12.7
Node: v14.16.0
Mongodb: 3.6.6
The text was updated successfully, but these errors were encountered: