File tree Expand file tree Collapse file tree
apps/web/src/features/upload Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -398,11 +398,26 @@ export async function processInstrumentCSV(
398398 instrument : AnyUnilingualFormInstrument
399399) : Promise < UploadOperationResult < FormTypes . Data [ ] > > {
400400 const instrumentSchema = instrument . validationSchema as z . AnyZodObject ;
401- const instrumentSchemaWithInternal = instrumentSchema . extend ( {
402- date : z . coerce . date ( ) ,
403- subjectID : z . string ( )
404- } ) ;
405- const shape = instrumentSchemaWithInternal . shape as { [ key : string ] : z . ZodTypeAny } ;
401+ let shape : { [ key : string ] : z . ZodTypeAny } = { } ;
402+ let instrumentSchemaWithInternal : z . AnyZodObject ;
403+
404+ if ( ( instrumentSchema . _def . typeName as string ) === 'ZodEffects' ) {
405+ // TODO - find a type safe way to call this
406+
407+ instrumentSchemaWithInternal = instrumentSchema . _def . schema . extend ( {
408+ date : z . coerce . date ( ) ,
409+ subjectID : z . string ( )
410+ } ) as z . AnyZodObject ;
411+
412+ shape = instrumentSchemaWithInternal . _def . shape ( ) as { [ key : string ] : z . ZodTypeAny } ;
413+ } else {
414+ //const shape2 = instrumentSchema.shape as { [key: string]: z.ZodTypeAny };
415+ instrumentSchemaWithInternal = instrumentSchema . extend ( {
416+ date : z . coerce . date ( ) ,
417+ subjectID : z . string ( )
418+ } ) ;
419+ shape = instrumentSchemaWithInternal . shape as { [ key : string ] : z . ZodTypeAny } ;
420+ }
406421
407422 return new Promise < UploadOperationResult < FormTypes . Data [ ] > > ( ( resolve ) => {
408423 const reader = new FileReader ( ) ;
You can’t perform that action at this time.
0 commit comments