joi 17.13.2 → 17.13.4

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.
@@ -328,10 +328,13 @@ internals.errors = function (failures, { error, state }) {
328
328
  const [type, code] = report.code.split('.');
329
329
  if (code !== 'base') {
330
330
  complex.push({ type: schema.type, report });
331
- continue;
332
331
  }
333
-
334
- valids.add(type);
332
+ else if (report.code === 'object.base') {
333
+ valids.add(report.local.type);
334
+ }
335
+ else {
336
+ valids.add(type);
337
+ }
335
338
  }
336
339
 
337
340
  // All errors are base types or valids
package/lib/types/link.js CHANGED
@@ -29,13 +29,25 @@ module.exports = Any.extend({
29
29
  return schema.ref(ref);
30
30
  },
31
31
 
32
- validate(value, { schema, state, prefs }) {
32
+ validate(value, { schema, state, prefs, error }) {
33
33
 
34
34
  Assert(schema.$_terms.link, 'Uninitialized link schema');
35
35
 
36
36
  const linked = internals.generate(schema, value, state, prefs);
37
37
  const ref = schema.$_terms.link[0].ref;
38
- return linked.$_validate(value, state.nest(linked, `link:${ref.display}:${linked.type}`), prefs);
38
+
39
+ try {
40
+ return linked.$_validate(value, state.nest(linked, `link:${ref.display}:${linked.type}`), prefs);
41
+ }
42
+ catch (err) {
43
+ /* $lab:coverage:off$ */
44
+ if (!(err instanceof RangeError)) {
45
+ throw err;
46
+ }
47
+ /* $lab:coverage:on$ */
48
+
49
+ return { value, errors: error('link.depth') };
50
+ }
39
51
  },
40
52
 
41
53
  generate(schema, value, state, prefs) {
@@ -88,6 +100,10 @@ module.exports = Any.extend({
88
100
  }
89
101
  },
90
102
 
103
+ messages: {
104
+ 'link.depth': '{{#label}} exceeds maximum recursion depth supported by the runtime'
105
+ },
106
+
91
107
  manifest: {
92
108
 
93
109
  build(obj, desc) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "joi",
3
3
  "description": "Object schema validation",
4
- "version": "17.13.2",
4
+ "version": "17.13.4",
5
5
  "repository": "git://github.com/hapijs/joi",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",