Allow undefined values in simple objects.
This commit is contained in:
parent
b6411c9401
commit
1641bb19dc
2 changed files with 5 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@sharkitek/core",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"description": "Sharkitek core models library.",
|
||||
"keywords": [
|
||||
"sharkitek",
|
||||
|
|
|
@ -24,7 +24,7 @@ export class ObjectType<Keys extends symbol|string> extends Type<Record<Keys, an
|
|||
// For each defined field, deserialize its value according to its type.
|
||||
(Object.entries(this.fieldsTypes) as [Keys, Definition<any, any>][]).map(([fieldName, fieldDefinition]) => (
|
||||
// Return an entry with the current field name and the deserialized value.
|
||||
[fieldName, fieldDefinition.type.deserialize(value[fieldName])]
|
||||
[fieldName, fieldDefinition.type.deserialize(value?.[fieldName])]
|
||||
))
|
||||
) as Record<Keys, any>;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ export class ObjectType<Keys extends symbol|string> extends Type<Record<Keys, an
|
|||
// For each defined field, serialize its value according to its type.
|
||||
(Object.entries(this.fieldsTypes) as [Keys, Definition<any, any>][]).map(([fieldName, fieldDefinition]) => (
|
||||
// Return an entry with the current field name and the serialized value.
|
||||
[fieldName, fieldDefinition.type.serialize(value[fieldName])]
|
||||
[fieldName, fieldDefinition.type.serialize(value?.[fieldName])]
|
||||
))
|
||||
) as Record<Keys, any>;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ export class ObjectType<Keys extends symbol|string> extends Type<Record<Keys, an
|
|||
// For each defined field, serialize its diff value according to its type.
|
||||
(Object.entries(this.fieldsTypes) as [Keys, Definition<any, any>][]).map(([fieldName, fieldDefinition]) => (
|
||||
// Return an entry with the current field name and the serialized diff value.
|
||||
[fieldName, fieldDefinition.type.serializeDiff(value[fieldName])]
|
||||
[fieldName, fieldDefinition.type.serializeDiff(value?.[fieldName])]
|
||||
))
|
||||
) as Record<Keys, any>;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ export class ObjectType<Keys extends symbol|string> extends Type<Record<Keys, an
|
|||
// For each field, reset its diff.
|
||||
(Object.entries(this.fieldsTypes) as [Keys, Definition<any, any>][]).forEach(([fieldName, fieldDefinition]) => {
|
||||
// Reset diff of the current field.
|
||||
fieldDefinition.type.resetDiff(value[fieldName]);
|
||||
fieldDefinition.type.resetDiff(value?.[fieldName]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue