Skip to content

Commit 892e32e

Browse files
committed
chore: deal with superRefine ZodEffect types
1 parent d5e17e4 commit 892e32e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

apps/web/src/features/upload/utils.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,15 @@ function generateSampleData({
362362
export function createUploadTemplateCSV(instrument: AnyUnilingualFormInstrument) {
363363
// TODO - type validationSchema as object
364364
const instrumentSchema = instrument.validationSchema as z.AnyZodObject;
365-
const shape = instrumentSchema.shape as { [key: string]: z.ZodTypeAny };
366365

367-
const columnNames = Object.keys(instrumentSchema.shape as z.AnyZodObject);
366+
let shape: { [key: string]: z.ZodTypeAny } = {};
367+
if ((instrumentSchema._def.typeName as string) === 'ZodEffects') {
368+
shape = instrumentSchema._def.schema._def.shape() as { [key: string]: z.ZodTypeAny };
369+
} else {
370+
shape = instrumentSchema.shape as { [key: string]: z.ZodTypeAny };
371+
}
372+
373+
const columnNames = Object.keys(shape);
368374

369375
const csvColumns = INTERNAL_HEADERS.concat(columnNames);
370376

0 commit comments

Comments
 (0)