Skip to content

Commit 86b6256

Browse files
committed
Fix for default values bug in undefined properties
1 parent 3f681c8 commit 86b6256

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/firecms_core/src/util/entities.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ export function getDefaultValuesFor<M extends Record<string, any>>(properties: P
4040
if (!properties) return {};
4141
return Object.entries(properties)
4242
.map(([key, property]) => {
43+
if (!property) return {};
4344
const value = getDefaultValueFor(property as PropertyOrBuilder);
4445
return value === undefined ? {} : { [key]: value };
4546
})
4647
.reduce((a, b) => ({ ...a, ...b }), {}) as EntityValues<M>;
4748
}
4849

49-
export function getDefaultValueFor(property: PropertyOrBuilder) {
50+
export function getDefaultValueFor(property?: PropertyOrBuilder) {
51+
if (!property) return undefined;
5052
if (isPropertyBuilder(property)) return undefined;
5153
if (property.defaultValue || property.defaultValue === null) {
5254
return property.defaultValue;

0 commit comments

Comments
 (0)