@sinclair/typebox 0.31.17 → 0.31.18
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/package.json +2 -2
- package/value/transform.js +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sinclair/typebox",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.18",
|
|
4
4
|
"description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"publish:dev": "hammer task publish_dev"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@sinclair/hammer": "^0.
|
|
55
|
+
"@sinclair/hammer": "^0.18.0",
|
|
56
56
|
"@types/mocha": "^9.1.1",
|
|
57
57
|
"@types/node": "^18.11.9",
|
|
58
58
|
"ajv": "^8.12.0",
|
package/value/transform.js
CHANGED
|
@@ -439,12 +439,20 @@ var EncodeTransform;
|
|
|
439
439
|
return (0, guard_1.IsArray)(schema.items) ? schema.items.map((schema, index) => Visit(schema, references, value1[index])) : [];
|
|
440
440
|
}
|
|
441
441
|
function TUnion(schema, references, value) {
|
|
442
|
+
// test value against union variants
|
|
442
443
|
for (const subschema of schema.anyOf) {
|
|
443
444
|
if (!checkFunction(subschema, references, value))
|
|
444
445
|
continue;
|
|
445
446
|
const value1 = Visit(subschema, references, value);
|
|
446
447
|
return Default(schema, value1);
|
|
447
448
|
}
|
|
449
|
+
// test transformed value against union variants
|
|
450
|
+
for (const subschema of schema.anyOf) {
|
|
451
|
+
const value1 = Visit(subschema, references, value);
|
|
452
|
+
if (!checkFunction(schema, references, value1))
|
|
453
|
+
continue;
|
|
454
|
+
return Default(schema, value1);
|
|
455
|
+
}
|
|
448
456
|
return Default(schema, value);
|
|
449
457
|
}
|
|
450
458
|
function Visit(schema, references, value) {
|