Skip to content

Commit

Permalink
Allow undefined values in simple objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
Madeorsk committed Sep 28, 2024
1 parent b6411c9 commit d96c39d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sharkitek/core",
"version": "2.1.0",
"version": "2.1.1",
"description": "Sharkitek core models library.",
"keywords": [
"sharkitek",
Expand Down
8 changes: 4 additions & 4 deletions src/Model/Types/ObjectType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}
Expand All @@ -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>;
}
Expand All @@ -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>;
}
Expand All @@ -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]);
});
}
}
Expand Down

0 comments on commit d96c39d

Please sign in to comment.