@sinclair/typebox 0.26.5 → 0.26.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/value/convert.js +14 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.26.5",
3
+ "version": "0.26.6",
4
4
  "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
package/value/convert.js CHANGED
@@ -30,6 +30,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.ValueConvert = exports.ValueConvertDereferenceError = exports.ValueConvertUnknownTypeError = void 0;
31
31
  const Types = require("../typebox");
32
32
  const clone_1 = require("./clone");
33
+ const check_1 = require("./check");
33
34
  // ----------------------------------------------------------------------------------------------
34
35
  // Errors
35
36
  // ----------------------------------------------------------------------------------------------
@@ -236,7 +237,13 @@ var ValueConvert;
236
237
  return value;
237
238
  }
238
239
  function Record(schema, references, value) {
239
- return value;
240
+ const propertyKey = globalThis.Object.getOwnPropertyNames(schema.patternProperties)[0];
241
+ const property = schema.patternProperties[propertyKey];
242
+ const result = {};
243
+ for (const [propKey, propValue] of globalThis.Object.entries(value)) {
244
+ result[propKey] = Visit(property, references, propValue);
245
+ }
246
+ return result;
240
247
  }
241
248
  function Ref(schema, references, value) {
242
249
  const index = references.findIndex((foreign) => foreign.$id === schema.$ref);
@@ -270,6 +277,12 @@ var ValueConvert;
270
277
  return TryConvertUndefined(value);
271
278
  }
272
279
  function Union(schema, references, value) {
280
+ for (const subschema of schema.anyOf) {
281
+ const converted = Visit(subschema, references, value);
282
+ if (check_1.ValueCheck.Check(subschema, references, converted)) {
283
+ return converted;
284
+ }
285
+ }
273
286
  return value;
274
287
  }
275
288
  function Uint8Array(schema, references, value) {