@depup/joi 18.1.1-depup.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.
package/lib/values.js ADDED
@@ -0,0 +1,262 @@
1
+ 'use strict';
2
+
3
+ const { assert, deepEqual } = require('@hapi/hoek');
4
+
5
+ const Common = require('./common');
6
+
7
+
8
+ const internals = {};
9
+
10
+
11
+ module.exports = internals.Values = class {
12
+
13
+ constructor(values, refs) {
14
+
15
+ this._values = new Set(values);
16
+ this._refs = new Set(refs);
17
+ this._lowercase = internals.lowercases(values);
18
+
19
+ this._override = false;
20
+ }
21
+
22
+ get length() {
23
+
24
+ return this._values.size + this._refs.size;
25
+ }
26
+
27
+ add(value, refs) {
28
+
29
+ // Reference
30
+
31
+ if (Common.isResolvable(value)) {
32
+ if (!this._refs.has(value)) {
33
+ this._refs.add(value);
34
+
35
+ if (refs) { // Skipped in a merge
36
+ refs.register(value);
37
+ }
38
+ }
39
+
40
+ return;
41
+ }
42
+
43
+ // Value
44
+
45
+ if (!this.has(value, null, null, false)) {
46
+ this._values.add(value);
47
+
48
+ if (typeof value === 'string') {
49
+ this._lowercase.set(value.toLowerCase(), value);
50
+ }
51
+ }
52
+ }
53
+
54
+ static merge(target, source, remove) {
55
+
56
+ target = target || new internals.Values();
57
+
58
+ if (source) {
59
+ if (source._override) {
60
+ return source.clone();
61
+ }
62
+
63
+ for (const item of [...source._values, ...source._refs]) {
64
+ target.add(item);
65
+ }
66
+ }
67
+
68
+ if (remove) {
69
+ for (const item of [...remove._values, ...remove._refs]) {
70
+ target.remove(item);
71
+ }
72
+ }
73
+
74
+ return target.length ? target : null;
75
+ }
76
+
77
+ remove(value) {
78
+
79
+ // Reference
80
+
81
+ if (Common.isResolvable(value)) {
82
+ this._refs.delete(value);
83
+ return;
84
+ }
85
+
86
+ // Value
87
+
88
+ this._values.delete(value);
89
+
90
+ if (typeof value === 'string') {
91
+ this._lowercase.delete(value.toLowerCase());
92
+ }
93
+ }
94
+
95
+ has(value, state, prefs, insensitive) {
96
+
97
+ return !!this.get(value, state, prefs, insensitive);
98
+ }
99
+
100
+ get(value, state, prefs, insensitive) {
101
+
102
+ if (!this.length) {
103
+ return false;
104
+ }
105
+
106
+ // Simple match
107
+
108
+ if (this._values.has(value)) {
109
+ return { value };
110
+ }
111
+
112
+ // Case insensitive string match
113
+
114
+ if (typeof value === 'string' &&
115
+ value &&
116
+ insensitive) {
117
+
118
+ const found = this._lowercase.get(value.toLowerCase());
119
+ if (found) {
120
+ return { value: found };
121
+ }
122
+ }
123
+
124
+ if (!this._refs.size &&
125
+ typeof value !== 'object') {
126
+
127
+ return false;
128
+ }
129
+
130
+ // Objects
131
+
132
+ if (typeof value === 'object') {
133
+ for (const item of this._values) {
134
+ if (deepEqual(item, value)) {
135
+ return { value: item };
136
+ }
137
+ }
138
+ }
139
+
140
+ // References
141
+
142
+ if (state) {
143
+ for (const ref of this._refs) {
144
+ const resolved = ref.resolve(value, state, prefs, null, { in: true });
145
+ if (resolved === undefined) {
146
+ continue;
147
+ }
148
+
149
+ const items = !ref.in || typeof resolved !== 'object'
150
+ ? [resolved]
151
+ : Array.isArray(resolved) ? resolved : Object.keys(resolved);
152
+
153
+ for (const item of items) {
154
+ if (typeof item !== typeof value) {
155
+ continue;
156
+ }
157
+
158
+ if (insensitive &&
159
+ value &&
160
+ typeof value === 'string') {
161
+
162
+ if (item.toLowerCase() === value.toLowerCase()) {
163
+ return { value: item, ref };
164
+ }
165
+ }
166
+ else {
167
+ if (deepEqual(item, value)) {
168
+ return { value: item, ref };
169
+ }
170
+ }
171
+ }
172
+ }
173
+ }
174
+
175
+ return false;
176
+ }
177
+
178
+ override() {
179
+
180
+ this._override = true;
181
+ }
182
+
183
+ values(options) {
184
+
185
+ if (options &&
186
+ options.display) {
187
+
188
+ const values = [];
189
+
190
+ for (const item of [...this._values, ...this._refs]) {
191
+ if (item !== undefined) {
192
+ values.push(item);
193
+ }
194
+ }
195
+
196
+ return values;
197
+ }
198
+
199
+ return Array.from([...this._values, ...this._refs]);
200
+ }
201
+
202
+ clone() {
203
+
204
+ const set = new internals.Values(this._values, this._refs);
205
+ set._override = this._override;
206
+ return set;
207
+ }
208
+
209
+ concat(source) {
210
+
211
+ assert(!source._override, 'Cannot concat override set of values');
212
+
213
+ const set = new internals.Values([...this._values, ...source._values], [...this._refs, ...source._refs]);
214
+ set._override = this._override;
215
+ return set;
216
+ }
217
+
218
+ describe() {
219
+
220
+ const normalized = [];
221
+
222
+ if (this._override) {
223
+ normalized.push({ override: true });
224
+ }
225
+
226
+ for (const value of this._values.values()) {
227
+ normalized.push(value && typeof value === 'object' ? { value } : value);
228
+ }
229
+
230
+ for (const value of this._refs.values()) {
231
+ normalized.push(value.describe());
232
+ }
233
+
234
+ return normalized;
235
+ }
236
+ };
237
+
238
+
239
+ internals.Values.prototype[Common.symbols.values] = true;
240
+
241
+
242
+ // Aliases
243
+
244
+ internals.Values.prototype.slice = internals.Values.prototype.clone;
245
+
246
+
247
+ // Helpers
248
+
249
+ internals.lowercases = function (from) {
250
+
251
+ const map = new Map();
252
+
253
+ if (from) {
254
+ for (const value of from) {
255
+ if (typeof value === 'string') {
256
+ map.set(value.toLowerCase(), value);
257
+ }
258
+ }
259
+ }
260
+
261
+ return map;
262
+ };
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@depup/joi",
3
+ "description": "Object schema validation (with updated dependencies)",
4
+ "version": "18.1.1-depup.0",
5
+ "repository": {
6
+ "url": "git://github.com/hapijs/joi.git",
7
+ "type": "git"
8
+ },
9
+ "engines": {
10
+ "node": ">= 20"
11
+ },
12
+ "main": "lib/index.js",
13
+ "types": "lib/index.d.ts",
14
+ "browser": "dist/joi-browser.min.js",
15
+ "files": [
16
+ "lib/**/*",
17
+ "dist/*",
18
+ "changes.json",
19
+ "README.md"
20
+ ],
21
+ "keywords": [
22
+ "joi",
23
+ "depup",
24
+ "updated-dependencies",
25
+ "security",
26
+ "latest",
27
+ "patched",
28
+ "schema",
29
+ "validation"
30
+ ],
31
+ "dependencies": {
32
+ "@hapi/address": "^5.1.1",
33
+ "@hapi/formula": "^3.0.2",
34
+ "@hapi/hoek": "^11.0.7",
35
+ "@hapi/pinpoint": "^2.0.1",
36
+ "@hapi/tlds": "^1.1.6",
37
+ "@hapi/topo": "^6.0.2",
38
+ "@standard-schema/spec": "^1.1.0"
39
+ },
40
+ "devDependencies": {
41
+ "@hapi/bourne": "^3.0.0",
42
+ "@hapi/code": "^9.0.3",
43
+ "@hapi/eslint-plugin": "^7.0.0",
44
+ "@hapi/joi-legacy-test": "npm:@hapi/joi@15.x.x",
45
+ "@hapi/lab": "^26.0.0",
46
+ "@types/node": "^20.17.47",
47
+ "ajv": "^8.18.0",
48
+ "typescript": "^5.8.3"
49
+ },
50
+ "scripts": {
51
+ "test": "lab -t 100 -a @hapi/code -L -Y",
52
+ "test-cov-html": "lab -r html -o coverage.html -a @hapi/code"
53
+ },
54
+ "license": "BSD-3-Clause",
55
+ "depup": {
56
+ "changes": {
57
+ "@hapi/tlds": {
58
+ "from": "^1.1.1",
59
+ "to": "^1.1.6"
60
+ }
61
+ },
62
+ "depsUpdated": 1,
63
+ "originalPackage": "joi",
64
+ "originalVersion": "18.1.1",
65
+ "processedAt": "2026-03-23T20:18:46.146Z",
66
+ "smokeTest": "passed"
67
+ }
68
+ }