Allow undefined values in simple objects.
This commit is contained in:
parent
b6411c9401
commit
d96c39d079
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sharkitek/core",
|
"name": "@sharkitek/core",
|
||||||
"version": "2.1.0",
|
"version": "2.1.1",
|
||||||
"description": "Sharkitek core models library.",
|
"description": "Sharkitek core models library.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"sharkitek",
|
"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.
|
// For each defined field, deserialize its value according to its type.
|
||||||
(Object.entries(this.fieldsTypes) as [Keys, Definition<any, any>][]).map(([fieldName, fieldDefinition]) => (
|
(Object.entries(this.fieldsTypes) as [Keys, Definition<any, any>][]).map(([fieldName, fieldDefinition]) => (
|
||||||
// Return an entry with the current field name and the deserialized value.
|
// 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>;
|
) 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.
|
// For each defined field, serialize its value according to its type.
|
||||||
(Object.entries(this.fieldsTypes) as [Keys, Definition<any, any>][]).map(([fieldName, fieldDefinition]) => (
|
(Object.entries(this.fieldsTypes) as [Keys, Definition<any, any>][]).map(([fieldName, fieldDefinition]) => (
|
||||||
// Return an entry with the current field name and the serialized value.
|
// 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>;
|
) 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.
|
// For each defined field, serialize its diff value according to its type.
|
||||||
(Object.entries(this.fieldsTypes) as [Keys, Definition<any, any>][]).map(([fieldName, fieldDefinition]) => (
|
(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.
|
// 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>;
|
) 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.
|
// For each field, reset its diff.
|
||||||
(Object.entries(this.fieldsTypes) as [Keys, Definition<any, any>][]).forEach(([fieldName, fieldDefinition]) => {
|
(Object.entries(this.fieldsTypes) as [Keys, Definition<any, any>][]).forEach(([fieldName, fieldDefinition]) => {
|
||||||
// Reset diff of the current field.
|
// Reset diff of the current field.
|
||||||
fieldDefinition.type.resetDiff(value[fieldName]);
|
fieldDefinition.type.resetDiff(value?.[fieldName]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user