Skip to content

Commit

Permalink
fix: hide errors pertaining to individual files when upload subsequen…
Browse files Browse the repository at this point in the history
…t docs
  • Loading branch information
asharonbaltazar committed Jan 23, 2025
1 parent 6151e57 commit 07d796a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion react-app/src/components/ActionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type EnforceSchemaProps<Shape extends z.ZodRawShape> = z.ZodObject<
attachments?: z.ZodObject<{
[Key in keyof Shape]: z.ZodObject<{
label: z.ZodDefault<z.ZodString>;
files: z.ZodTypeAny;
files: z.ZodArray<z.ZodTypeAny, "many"> | z.ZodOptional<z.ZodArray<z.ZodTypeAny, "many">>;
}>;
}>;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ const pickAttachmentsAndAdditionalInfo = (
const shape = schema._def.shape();

const optionalAttachmentsShape = Object.fromEntries(
Object.entries(shape.attachments.shape).map(([key, value]) => [
key,
z.object({
files: value._def.shape().files.optional(),
label: value._def.shape().label,
}),
]),
Object.entries(shape.attachments.shape).map(([key, value]) => {
const files = value._def.shape().files;
const filesArray = files instanceof z.ZodArray ? files : files.unwrap();

return [
key,
z.object({
files: z.array(filesArray.element).optional(),
label: value._def.shape().label,
}),
];
}),
);

return z
Expand Down

0 comments on commit 07d796a

Please sign in to comment.