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 @@ -486,14 +486,14 @@ export async function processInstrumentCSV(
486486 //TODO make this type safe without having to cast z.AnyZodObject
487487 instrumentSchemaWithInternal = ( instrumentSchemaDef . schema as z . AnyZodObject ) . extend ( {
488488 date : z . coerce . date ( ) ,
489- subjectID : z . string ( )
489+ subjectID : z . string ( ) . regex ( / ^ [ ^ $ ] + $ / , 'Subject ID has to be at least 1 character long and without a $' )
490490 } ) ;
491491
492492 shape = instrumentSchemaWithInternal . _def . shape ( ) as { [ key : string ] : z . ZodTypeAny } ;
493493 } else {
494494 instrumentSchemaWithInternal = instrumentSchema . extend ( {
495495 date : z . coerce . date ( ) ,
496- subjectID : z . string ( )
496+ subjectID : z . string ( ) . regex ( / ^ [ ^ $ ] + $ / , 'Subject ID has to be at least 1 character long and without a $' )
497497 } ) ;
498498 shape = instrumentSchemaWithInternal . shape as { [ key : string ] : z . ZodTypeAny } ;
499499 }
@@ -571,8 +571,11 @@ export async function processInstrumentCSV(
571571 //create error message with zodcheck error messsage + zodcheck error path
572572 //addNotification({ message: zodCheck.error.issues[0]?.message, type: 'error' });
573573 console . error ( zodCheck . error . issues ) ;
574+ const zodIssues = zodCheck . error . issues . map ( ( issue ) => {
575+ return `issue message: \n ${ issue . message } \n path: ${ issue . path . toString ( ) } "` ;
576+ } ) ;
574577 console . error ( `Failed to parse data: ${ JSON . stringify ( jsonLine ) } ` ) ;
575- return resolve ( { message : zodCheck . error . message , success : false } ) ;
578+ return resolve ( { message : zodIssues . join ( ) , success : false } ) ;
576579 }
577580 result . push ( zodCheck . data ) ;
578581 }
You can’t perform that action at this time.
0 commit comments