Document.prototype.validateSync()
Parameters
pathsToValidate «Array|string» only validate the given paths
[options] «Object» options for validation
[options.validateModifiedOnly=false] «Boolean» If
true
, Mongoose will only validate modified paths, as opposed to modified paths andrequired
paths.
Returns:
- «ValidationError,undefined» ValidationError if there are errors during validation, or undefined if there is no error.
Executes registered validation rules (skipping asynchronous validators) for this document.
Note:
This method is useful if you need synchronous validation.
Example:
const err = doc.validateSync();
if (err) {
handleError(err);
} else {
// validation passed
}
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .