@naturalcycles/nodejs-lib 12.93.2 → 12.94.0

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.
@@ -110,17 +110,23 @@ function createError(value, err, objectName) {
110
110
  tokens.push('Invalid ' + [objectName, objectId].filter(Boolean).join('.'));
111
111
  }
112
112
  const annotation = err.annotate(stripColors);
113
- if (annotation.length > 4000) {
114
- // Annotation message is too big and will be replaced by stringified `error.details` instead
115
- tokens.push((0, js_lib_1._truncateMiddle)(annotation, 4000, `\n... ${(0, js_lib_1._hb)(annotation.length)} message truncated ...\n`));
113
+ if (annotation.length > 100) {
114
+ // For rather large annotations - we include up to 5 errors up front, before printing the whole object.
116
115
  // Up to 5 `details`
117
- tokens.push(...err.details.slice(0, 5).map(i => `${i.message} @ .${i.path.join('.')}`));
116
+ tokens.push(...err.details.slice(0, 5).map(i => {
117
+ return i.message;
118
+ // Currently not specifying the path, to not "overwhelm" the message
119
+ // Can be reverted if needed.
120
+ // let msg = i.message
121
+ // const paths = i.path.filter(Boolean).join('.')
122
+ // if (paths) msg += ` @ .${paths}`
123
+ // return msg
124
+ }));
118
125
  if (err.details.length > 5)
119
- tokens.push(`... ${err.details.length} errors`);
120
- }
121
- else {
122
- tokens.push(annotation);
126
+ tokens.push(`... ${err.details.length} errors in total`);
127
+ tokens.push('');
123
128
  }
129
+ tokens.push((0, js_lib_1._truncateMiddle)(annotation, 4000, `\n... ${(0, js_lib_1._hb)(annotation.length)} message truncated ...\n`));
124
130
  const msg = tokens.join('\n');
125
131
  const data = {
126
132
  joiValidationErrorItems: err.details,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "12.93.2",
3
+ "version": "12.94.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
@@ -146,21 +146,30 @@ function createError(value: any, err: ValidationError, objectName?: string): Joi
146
146
 
147
147
  const annotation = err.annotate(stripColors)
148
148
 
149
- if (annotation.length > 4000) {
150
- // Annotation message is too big and will be replaced by stringified `error.details` instead
149
+ if (annotation.length > 100) {
150
+ // For rather large annotations - we include up to 5 errors up front, before printing the whole object.
151
151
 
152
+ // Up to 5 `details`
152
153
  tokens.push(
153
- _truncateMiddle(annotation, 4000, `\n... ${_hb(annotation.length)} message truncated ...\n`),
154
+ ...err.details.slice(0, 5).map(i => {
155
+ return i.message
156
+ // Currently not specifying the path, to not "overwhelm" the message
157
+ // Can be reverted if needed.
158
+ // let msg = i.message
159
+ // const paths = i.path.filter(Boolean).join('.')
160
+ // if (paths) msg += ` @ .${paths}`
161
+ // return msg
162
+ }),
154
163
  )
155
164
 
156
- // Up to 5 `details`
157
- tokens.push(...err.details.slice(0, 5).map(i => `${i.message} @ .${i.path.join('.')}`))
158
-
159
- if (err.details.length > 5) tokens.push(`... ${err.details.length} errors`)
160
- } else {
161
- tokens.push(annotation)
165
+ if (err.details.length > 5) tokens.push(`... ${err.details.length} errors in total`)
166
+ tokens.push('')
162
167
  }
163
168
 
169
+ tokens.push(
170
+ _truncateMiddle(annotation, 4000, `\n... ${_hb(annotation.length)} message truncated ...\n`),
171
+ )
172
+
164
173
  const msg = tokens.join('\n')
165
174
 
166
175
  const data: JoiValidationErrorData = {