From d96c39d0790d8b7fedb5f090382f4b8b8759efc6 Mon Sep 17 00:00:00 2001 From: Madeorsk Date: Sat, 28 Sep 2024 17:18:12 +0200 Subject: [PATCH] Allow undefined values in simple objects. --- package.json | 2 +- src/Model/Types/ObjectType.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 293f9cc..c5ec456 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sharkitek/core", - "version": "2.1.0", + "version": "2.1.1", "description": "Sharkitek core models library.", "keywords": [ "sharkitek", diff --git a/src/Model/Types/ObjectType.ts b/src/Model/Types/ObjectType.ts index 22c85fb..61abc21 100644 --- a/src/Model/Types/ObjectType.ts +++ b/src/Model/Types/ObjectType.ts @@ -24,7 +24,7 @@ export class ObjectType extends Type][]).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; } @@ -38,7 +38,7 @@ export class ObjectType extends Type][]).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; } @@ -52,7 +52,7 @@ export class ObjectType extends Type][]).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; } @@ -62,7 +62,7 @@ export class ObjectType extends Type][]).forEach(([fieldName, fieldDefinition]) => { // Reset diff of the current field. - fieldDefinition.type.resetDiff(value[fieldName]); + fieldDefinition.type.resetDiff(value?.[fieldName]); }); } }