We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
mongoosejs
Learn more about funding links in repositories.
Report abuse
1 parent 13ae085 commit cec9ddaCopy full SHA for cec9dda
lib/error/validation.js
@@ -17,20 +17,23 @@ const util = require('util');
17
18
function ValidationError(instance) {
19
this.errors = {};
20
+ this.name = 'ValidationError';
21
this._message = '';
22
+
23
if (instance && instance.constructor.name === 'model') {
24
this._message = instance.constructor.modelName + ' validation failed';
- MongooseError.call(this, this._message);
25
} else {
26
this._message = 'Validation failed';
27
}
28
- this.name = 'ValidationError';
29
+ MongooseError.call(this, this._message);
30
31
if (Error.captureStackTrace) {
32
Error.captureStackTrace(this);
33
34
this.stack = new Error().stack;
35
36
37
if (instance) {
38
instance.errors = this.errors;
39
0 commit comments