diff --git a/packages/uniforms-bridge-zod/src/ZodBridge.ts b/packages/uniforms-bridge-zod/src/ZodBridge.ts index 6c7a241c2..04661bb32 100644 --- a/packages/uniforms-bridge-zod/src/ZodBridge.ts +++ b/packages/uniforms-bridge-zod/src/ZodBridge.ts @@ -8,6 +8,7 @@ import { ZodBoolean, ZodDate, ZodDefault, + ZodEffects, ZodEnum, ZodError, ZodNativeEnum, @@ -37,14 +38,14 @@ type Option = { }; export default class ZodBridge extends Bridge { - schema: ZodObject; + schema: ZodObject | ZodEffects>; provideDefaultLabelFromFieldName: boolean; constructor({ schema, provideDefaultLabelFromFieldName = true, }: { - schema: ZodObject; + schema: ZodObject | ZodEffects>; provideDefaultLabelFromFieldName?: boolean; }) { super(); @@ -87,6 +88,11 @@ export default class ZodBridge extends Bridge { getField(name: string) { let field: ZodType = this.schema; + + if (this.schema instanceof ZodEffects) { + field = this.schema._def.schema; + } + for (const key of joinName(null, name)) { if (field instanceof ZodDefault) { field = field.removeDefault();