mongoose 8.24.11 → 8.24.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.umd.js +1 -1
- package/lib/error/validator.js +12 -1
- package/package.json +1 -1
package/lib/error/validator.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
7
|
const MongooseError = require('./mongooseError');
|
|
8
|
+
const util = require('util');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Schema validator error
|
|
@@ -87,7 +88,17 @@ function formatMessage(msg, properties, doc) {
|
|
|
87
88
|
if (propertyName === 'message') {
|
|
88
89
|
continue;
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
+
const token = '{' + propertyName.toUpperCase() + '}';
|
|
92
|
+
if (!msg.includes(token)) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
let value;
|
|
96
|
+
try {
|
|
97
|
+
value = String(properties[propertyName]);
|
|
98
|
+
} catch {
|
|
99
|
+
value = util.inspect(properties[propertyName]);
|
|
100
|
+
}
|
|
101
|
+
msg = msg.replace(token, value);
|
|
91
102
|
}
|
|
92
103
|
|
|
93
104
|
return msg;
|