From bd93a6520b5074756cc3a8284068e4885f658a30 Mon Sep 17 00:00:00 2001 From: Myles J Date: Tue, 1 Nov 2022 14:12:58 +0000 Subject: [PATCH] feat(attributes): dynamic default --- packages/core/src/helpers/getAttributesFromExtensions.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/src/helpers/getAttributesFromExtensions.ts b/packages/core/src/helpers/getAttributesFromExtensions.ts index 65de01adf4e..5cab0cf92ce 100644 --- a/packages/core/src/helpers/getAttributesFromExtensions.ts +++ b/packages/core/src/helpers/getAttributesFromExtensions.ts @@ -93,7 +93,11 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt ...attribute, } - if (attribute?.isRequired && attribute?.default === undefined) { + if(typeof mergedAttr?.default === 'function') { + mergedAttr.default = mergedAttr.default() + } + + if (mergedAttr?.isRequired && mergedAttr?.default === undefined) { delete mergedAttr.default }