@sinclair/typebox 0.33.5 → 0.33.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.
@@ -49,22 +49,25 @@ function FromObject(schema, references, value) {
49
49
  const defaulted = ValueOrDefault(schema, value);
50
50
  if (!(0, index_5.IsObject)(defaulted))
51
51
  return defaulted;
52
- const additionalPropertiesSchema = schema.additionalProperties;
53
52
  const knownPropertyKeys = Object.getOwnPropertyNames(schema.properties);
54
53
  // properties
55
54
  for (const key of knownPropertyKeys) {
56
- if (!HasDefaultProperty(schema.properties[key]))
55
+ // note: we need to traverse into the object and test if the return value
56
+ // yielded a non undefined result. Here we interpret an undefined result as
57
+ // a non assignable property and continue.
58
+ const propertyValue = Visit(schema.properties[key], references, defaulted[key]);
59
+ if ((0, index_5.IsUndefined)(propertyValue))
57
60
  continue;
58
- defaulted[key] = Visit(schema.properties[key], references, defaulted[key]);
61
+ defaulted[key] = propertyValue;
59
62
  }
60
63
  // return if not additional properties
61
- if (!HasDefaultProperty(additionalPropertiesSchema))
64
+ if (!HasDefaultProperty(schema.additionalProperties))
62
65
  return defaulted;
63
66
  // additional properties
64
67
  for (const key of Object.getOwnPropertyNames(defaulted)) {
65
68
  if (knownPropertyKeys.includes(key))
66
69
  continue;
67
- defaulted[key] = Visit(additionalPropertiesSchema, references, defaulted[key]);
70
+ defaulted[key] = Visit(schema.additionalProperties, references, defaulted[key]);
68
71
  }
69
72
  return defaulted;
70
73
  }
@@ -45,22 +45,25 @@ function FromObject(schema, references, value) {
45
45
  const defaulted = ValueOrDefault(schema, value);
46
46
  if (!IsObject(defaulted))
47
47
  return defaulted;
48
- const additionalPropertiesSchema = schema.additionalProperties;
49
48
  const knownPropertyKeys = Object.getOwnPropertyNames(schema.properties);
50
49
  // properties
51
50
  for (const key of knownPropertyKeys) {
52
- if (!HasDefaultProperty(schema.properties[key]))
51
+ // note: we need to traverse into the object and test if the return value
52
+ // yielded a non undefined result. Here we interpret an undefined result as
53
+ // a non assignable property and continue.
54
+ const propertyValue = Visit(schema.properties[key], references, defaulted[key]);
55
+ if (IsUndefined(propertyValue))
53
56
  continue;
54
- defaulted[key] = Visit(schema.properties[key], references, defaulted[key]);
57
+ defaulted[key] = propertyValue;
55
58
  }
56
59
  // return if not additional properties
57
- if (!HasDefaultProperty(additionalPropertiesSchema))
60
+ if (!HasDefaultProperty(schema.additionalProperties))
58
61
  return defaulted;
59
62
  // additional properties
60
63
  for (const key of Object.getOwnPropertyNames(defaulted)) {
61
64
  if (knownPropertyKeys.includes(key))
62
65
  continue;
63
- defaulted[key] = Visit(additionalPropertiesSchema, references, defaulted[key]);
66
+ defaulted[key] = Visit(schema.additionalProperties, references, defaulted[key]);
64
67
  }
65
68
  return defaulted;
66
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.33.5",
3
+ "version": "0.33.6",
4
4
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",