diff --git a/lib/type-helpers/partial-type.helper.ts b/lib/type-helpers/partial-type.helper.ts index 03d3ddde1..b13571a6e 100644 --- a/lib/type-helpers/partial-type.helper.ts +++ b/lib/type-helpers/partial-type.helper.ts @@ -34,6 +34,15 @@ export function PartialType(classRef: Type): Type> { mapValues(metadata, (item) => ({ ...item, required: false })) ); + if (PartialTypeClass[METADATA_FACTORY_NAME]) { + const pluginFields = Object.keys( + PartialTypeClass[METADATA_FACTORY_NAME]() + ); + pluginFields.forEach((key) => + applyIsOptionalDecorator(PartialTypeClass, key) + ); + } + fields.forEach((key) => { const metadata = Reflect.getMetadata( @@ -59,12 +68,5 @@ export function PartialType(classRef: Type): Type> { applyFields(fields); }); - if (PartialTypeClass[METADATA_FACTORY_NAME]) { - const pluginFields = Object.keys(PartialTypeClass[METADATA_FACTORY_NAME]()); - pluginFields.forEach((key) => - applyIsOptionalDecorator(PartialTypeClass, key) - ); - } - return PartialTypeClass as Type>; }