joi 17.13.2 → 18.0.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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Assert = require('@hapi/hoek/lib/assert');
3
+ const { assert } = require('@hapi/hoek');
4
4
 
5
5
  const Any = require('./any');
6
6
 
@@ -62,17 +62,17 @@ module.exports = Any.extend({
62
62
  iterable = Object.entries(iterable);
63
63
  }
64
64
 
65
- Assert(iterable && iterable[Symbol.iterator], 'Iterable must be an iterable or object');
65
+ assert(iterable && iterable[Symbol.iterator], 'Iterable must be an iterable or object');
66
66
 
67
67
  const obj = this.clone();
68
68
 
69
69
  const symbols = [];
70
70
  for (const entry of iterable) {
71
- Assert(entry && entry[Symbol.iterator], 'Entry must be an iterable');
71
+ assert(entry && entry[Symbol.iterator], 'Entry must be an iterable');
72
72
  const [key, value] = entry;
73
73
 
74
- Assert(typeof key !== 'object' && typeof key !== 'function' && typeof key !== 'symbol', 'Key must not be of type object, function, or Symbol');
75
- Assert(typeof value === 'symbol', 'Value must be a Symbol');
74
+ assert(typeof key !== 'object' && typeof key !== 'function' && typeof key !== 'symbol', 'Key must not be of type object, function, or Symbol');
75
+ assert(typeof value === 'symbol', 'Value must be a Symbol');
76
76
 
77
77
  obj.$_terms.map.set(key, value);
78
78
  symbols.push(value);
package/lib/validator.js CHANGED
@@ -1,9 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Assert = require('@hapi/hoek/lib/assert');
4
- const Clone = require('@hapi/hoek/lib/clone');
5
- const Ignore = require('@hapi/hoek/lib/ignore');
6
- const Reach = require('@hapi/hoek/lib/reach');
3
+ const { assert, clone, ignore, reach } = require('@hapi/hoek');
7
4
 
8
5
  const Common = require('./common');
9
6
  const Errors = require('./errors');
@@ -19,13 +16,13 @@ exports.entry = function (value, schema, prefs) {
19
16
 
20
17
  let settings = Common.defaults;
21
18
  if (prefs) {
22
- Assert(prefs.warnings === undefined, 'Cannot override warnings preference in synchronous validation');
23
- Assert(prefs.artifacts === undefined, 'Cannot override artifacts preference in synchronous validation');
19
+ assert(prefs.warnings === undefined, 'Cannot override warnings preference in synchronous validation');
20
+ assert(prefs.artifacts === undefined, 'Cannot override artifacts preference in synchronous validation');
24
21
  settings = Common.preferences(Common.defaults, prefs);
25
22
  }
26
23
 
27
24
  const result = internals.entry(value, schema, settings);
28
- Assert(!result.mainstay.externals.length, 'Schema with external rules must use validateAsync()');
25
+ assert(!result.mainstay.externals.length, 'Schema with external rules must use validateAsync()');
29
26
  const outcome = { value: result.value };
30
27
 
31
28
  if (result.error) {
@@ -76,7 +73,7 @@ exports.entryAsync = async function (value, schema, prefs) {
76
73
  let parent;
77
74
 
78
75
  const ancestors = path.length ? [root] : [];
79
- const original = path.length ? Reach(value, path) : value;
76
+ const original = path.length ? reach(value, path) : value;
80
77
 
81
78
  if (path.length) {
82
79
  key = path[path.length - 1];
@@ -189,6 +186,17 @@ exports.entryAsync = async function (value, schema, prefs) {
189
186
  };
190
187
 
191
188
 
189
+ exports.standard = function (value, schema) {
190
+
191
+
192
+ if (schema.isAsync()) {
193
+ return exports.entryAsync(value, schema);
194
+ }
195
+
196
+ return exports.entry(value, schema);
197
+ };
198
+
199
+
192
200
  internals.Mainstay = class {
193
201
 
194
202
  constructor(tracer, debug, links) {
@@ -259,7 +267,7 @@ internals.tracer = function (schema, prefs) {
259
267
  }
260
268
 
261
269
  if (prefs.debug) {
262
- Assert(schema.$_root.trace, 'Debug mode not supported');
270
+ assert(schema.$_root.trace, 'Debug mode not supported');
263
271
  return { tracer: schema.$_root.trace()._register(schema), cleanup: true };
264
272
  }
265
273
 
@@ -575,7 +583,7 @@ internals.finalize = function (value, errors, helpers) {
575
583
  }
576
584
 
577
585
  for (const error of errors) {
578
- Assert(error instanceof Error || error instanceof Errors.Report, 'error() must return an Error object');
586
+ assert(error instanceof Error || error instanceof Errors.Report, 'error() must return an Error object');
579
587
  }
580
588
  }
581
589
  else {
@@ -687,7 +695,7 @@ internals.default = function (flag, value, errors, helpers) {
687
695
  }
688
696
 
689
697
  if (typeof source === 'function') {
690
- const args = source.length ? [Clone(state.ancestors[0]), helpers] : [];
698
+ const args = source.length ? [clone(state.ancestors[0]), helpers] : [];
691
699
 
692
700
  try {
693
701
  return source(...args);
@@ -710,7 +718,7 @@ internals.default = function (flag, value, errors, helpers) {
710
718
  return source.resolve(value, state, prefs);
711
719
  }
712
720
 
713
- return Clone(source);
721
+ return clone(source);
714
722
  };
715
723
 
716
724
 
@@ -733,12 +741,12 @@ internals.trim = function (value, schema) {
733
741
 
734
742
  internals.ignore = {
735
743
  active: false,
736
- debug: Ignore,
737
- entry: Ignore,
738
- filter: Ignore,
739
- log: Ignore,
740
- resolve: Ignore,
741
- value: Ignore
744
+ debug: ignore,
745
+ entry: ignore,
746
+ filter: ignore,
747
+ log: ignore,
748
+ resolve: ignore,
749
+ value: ignore
742
750
  };
743
751
 
744
752
 
package/lib/values.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Assert = require('@hapi/hoek/lib/assert');
4
- const DeepEqual = require('@hapi/hoek/lib/deepEqual');
3
+ const { assert, deepEqual } = require('@hapi/hoek');
5
4
 
6
5
  const Common = require('./common');
7
6
 
@@ -132,7 +131,7 @@ module.exports = internals.Values = class {
132
131
 
133
132
  if (typeof value === 'object') {
134
133
  for (const item of this._values) {
135
- if (DeepEqual(item, value)) {
134
+ if (deepEqual(item, value)) {
136
135
  return { value: item };
137
136
  }
138
137
  }
@@ -165,7 +164,7 @@ module.exports = internals.Values = class {
165
164
  }
166
165
  }
167
166
  else {
168
- if (DeepEqual(item, value)) {
167
+ if (deepEqual(item, value)) {
169
168
  return { value: item, ref };
170
169
  }
171
170
  }
@@ -209,7 +208,7 @@ module.exports = internals.Values = class {
209
208
 
210
209
  concat(source) {
211
210
 
212
- Assert(!source._override, 'Cannot concat override set of values');
211
+ assert(!source._override, 'Cannot concat override set of values');
213
212
 
214
213
  const set = new internals.Values([...this._values, ...source._values], [...this._refs, ...source._refs]);
215
214
  set._override = this._override;
package/package.json CHANGED
@@ -1,8 +1,14 @@
1
1
  {
2
2
  "name": "joi",
3
3
  "description": "Object schema validation",
4
- "version": "17.13.2",
5
- "repository": "git://github.com/hapijs/joi",
4
+ "version": "18.0.0",
5
+ "repository": {
6
+ "url": "git://github.com/hapijs/joi",
7
+ "type": "git"
8
+ },
9
+ "engines": {
10
+ "node": ">= 20"
11
+ },
6
12
  "main": "lib/index.js",
7
13
  "types": "lib/index.d.ts",
8
14
  "browser": "dist/joi-browser.min.js",
@@ -15,19 +21,22 @@
15
21
  "validation"
16
22
  ],
17
23
  "dependencies": {
18
- "@hapi/hoek": "^9.3.0",
19
- "@hapi/topo": "^5.1.0",
20
- "@sideway/address": "^4.1.5",
21
- "@sideway/formula": "^3.0.1",
22
- "@sideway/pinpoint": "^2.0.0"
24
+ "@hapi/address": "^5.1.1",
25
+ "@hapi/formula": "^3.0.2",
26
+ "@hapi/hoek": "^11.0.7",
27
+ "@hapi/pinpoint": "^2.0.1",
28
+ "@hapi/tlds": "^1.1.1",
29
+ "@hapi/topo": "^6.0.2",
30
+ "@standard-schema/spec": "^1.0.0"
23
31
  },
24
32
  "devDependencies": {
25
- "@hapi/bourne": "2.x.x",
26
- "@hapi/code": "8.x.x",
33
+ "@hapi/bourne": "^3.0.0",
34
+ "@hapi/code": "^9.0.3",
35
+ "@hapi/eslint-plugin": "^7.0.0",
27
36
  "@hapi/joi-legacy-test": "npm:@hapi/joi@15.x.x",
28
- "@hapi/lab": "^25.1.3",
29
- "@types/node": "^14.18.63",
30
- "typescript": "4.3.x"
37
+ "@hapi/lab": "^26.0.0",
38
+ "@types/node": "^20.17.47",
39
+ "typescript": "^5.8.3"
31
40
  },
32
41
  "scripts": {
33
42
  "prepublishOnly": "cd browser && npm install && npm run build",