Document.prototype.validate()
Parameters
[pathsToValidate] «Array|String» list of paths to validate. If set, Mongoose will validate only the modified paths that are in the given list.
[options] «Object» internal options
[options.validateModifiedOnly=false] «Boolean» if
true
mongoose validates only modified paths.[callback] «Function» optional callback called after validation completes, passing an error if one occurred
Returns:
- «Promise» Promise
Executes registered validation rules for this document.
Note:
This method is called pre
save and if a validation rule is violated, save is aborted and the error is returned to your callback
.
Example:
doc.validate(function (err) {
if (err) handleError(err);
else // validation passed
});
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .