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

fix doc.validate doc #13638

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 3 additions & 7 deletions lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -2521,21 +2521,17 @@ Document.prototype.isDirectSelected = function isDirectSelected(path) {
*
* #### Note:
*
* This method is called `pre` save and if a validation rule is violated, [save](https://mongoosejs.com/docs/api/model.html#Model.prototype.save()) is aborted and the error is returned to your `callback`.
* This method is called `pre` save and if a validation rule is violated, [save](https://mongoosejs.com/docs/api/model.html#Model.prototype.save()) is aborted and the error is thrown.
*
* #### Example:
*
* doc.validate(function (err) {
* if (err) handleError(err);
* else // validation passed
* });
* await doc.validate({ validateModifiedOnly: false, pathsToSkip: ['name', 'email']});
*
* @param {Array|String} [pathsToValidate] list of paths to validate. If set, Mongoose will validate only the modified paths that are in the given list.
* @param {Object} [options] internal options
* @param {Boolean} [options.validateModifiedOnly=false] if `true` mongoose validates only modified paths.
* @param {Array|string} [options.pathsToSkip] list of paths to skip. If set, Mongoose will validate every modified path that is not in this list.
* @param {Function} [callback] optional callback called after validation completes, passing an error if one occurred
* @return {Promise} Returns a Promise if no `callback` is given.
* @return {Promise} Returns a Promise.
* @api public
*/

Expand Down