Skip to content

Commit

Permalink
Fixed optional array fields (Zod bridge) (#1352)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrpospiech authored Jul 25, 2024
1 parent 91c1e21 commit 9957632
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/uniforms-bridge-zod/src/ZodBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ export default class ZodBridge<T extends ZodRawShape> extends Bridge {
}

getInitialValue(name: string): unknown {
const field = this.getField(name);
let field = this.getField(name);

if (field instanceof ZodOptional) {
field = field.unwrap();
}

if (field instanceof ZodArray) {
const item = this.getInitialValue(joinName(name, '$'));
if (item === undefined) {
Expand Down

0 comments on commit 9957632

Please sign in to comment.