typebox 1.0.60 → 1.0.61
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type TProperties, type TObject } from '../../type/index.mjs';
|
|
2
2
|
export declare function FromObject(context: TProperties, type: TObject, value: unknown): unknown;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
// deno-lint-ignore-file
|
|
3
|
+
import { IsOptional } from '../../type/index.mjs';
|
|
3
4
|
import { Guard } from '../../guard/index.mjs';
|
|
4
5
|
import { FromType } from './from-type.mjs';
|
|
5
6
|
import { IsAdditionalProperties } from '../../schema/types/index.mjs';
|
|
@@ -9,12 +10,13 @@ export function FromObject(context, type, value) {
|
|
|
9
10
|
const knownPropertyKeys = Guard.Keys(type.properties);
|
|
10
11
|
// Properties
|
|
11
12
|
for (const key of knownPropertyKeys) {
|
|
12
|
-
//
|
|
13
|
-
// yielded a non undefined result. Here we interpret an undefined result as
|
|
14
|
-
// a non assignable property and continue.
|
|
13
|
+
// Resolve Value for Property
|
|
15
14
|
const propertyValue = FromType(context, type.properties[key], value[key]);
|
|
16
|
-
|
|
15
|
+
// Ambiguious Undefined: If the value is undefined, the type is optional there's no default. ignore.
|
|
16
|
+
const isUnassignableUndefined = Guard.IsUndefined(propertyValue) && (IsOptional(type.properties[key]) || !Guard.HasPropertyKey(type.properties[key], 'default'));
|
|
17
|
+
if (isUnassignableUndefined)
|
|
17
18
|
continue;
|
|
19
|
+
// Assign
|
|
18
20
|
value[key] = FromType(context, type.properties[key], value[key]);
|
|
19
21
|
}
|
|
20
22
|
// return if not additional properties
|