typebox 1.0.39 → 1.0.40

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.
@@ -2,6 +2,8 @@
2
2
  import { Arguments } from '../../system/arguments/index.mjs';
3
3
  import { FromType } from './from-type.mjs';
4
4
  import { Assert } from '../assert/index.mjs';
5
+ import { Check } from '../check/index.mjs';
6
+ import { Create } from '../create/index.mjs';
5
7
  /**
6
8
  * Repairs a value to match the provided type. This function is intended for data migration
7
9
  * scenarios where existing values need to be migrating to an updated type. This function will
@@ -14,7 +16,8 @@ export function Repair(...args) {
14
16
  3: (context, type, value) => [context, type, value],
15
17
  2: (type, value) => [{}, type, value],
16
18
  });
17
- const result = FromType(context, type, value);
18
- Assert(context, type, result); // ensure correct
19
- return result;
19
+ const repaired = FromType(context, type, value);
20
+ const checked = Check(context, type, repaired) ? repaired : Create(context, type);
21
+ Assert(context, type, checked); // ensure correct
22
+ return checked;
20
23
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.0.39",
4
+ "version": "1.0.40",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"