Skip to content
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

Docs Typo: pathsToValidate > pathsOrOptions #14003

Closed
2 tasks done
titanism opened this issue Oct 24, 2023 · 1 comment
Closed
2 tasks done

Docs Typo: pathsToValidate > pathsOrOptions #14003

titanism opened this issue Oct 24, 2023 · 1 comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone

Comments

@titanism
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

all

Node.js version

all

MongoDB server version

all

Typescript version (if applicable)

No response

Description

pathsToValidate is used in the codebase but the docs say pathsOrOptions right now

we should also add the note from lib/document.js of:

list of paths to validate. If set, Mongoose will validate only the modified paths that are in the given list.

References: https://github.com/search?q=repo%3AAutomattic%2Fmongoose%20pathsOrOptions&type=code

Steps to Reproduce

see above

Expected Behavior

No response

@vkarpov15 vkarpov15 modified the milestones: 7.6.4, 7.6.5 Oct 25, 2023
@vkarpov15 vkarpov15 added the docs This issue is due to a mistake or omission in the mongoosejs.com documentation label Oct 25, 2023
@vkarpov15
Copy link
Collaborator

Oh I think the issue is that you're mixing up Document.prototype.validate(), which has a pathsToValidate parameter; with Model.validate(), which has a pathsOrOptions parameter.

  • list of paths to validate. If set, Mongoose will validate only the modified paths that are in the given list. is from Document.prototype.validate() docs
  • pathsOrOptions is a parameter to Model.validate().

Model.validate() is the static function that lets you validate an arbitrary object against the model's schema. Document.prototype.validate() is a method that runs validation on a document, which is an instance of a model.

vkarpov15 added a commit that referenced this issue Nov 16, 2023
vkarpov15 added a commit that referenced this issue Nov 21, 2023
types(model): support calling `Model.validate()` with `pathsToSkip` option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

No branches or pull requests

2 participants