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 @@ -62,6 +62,10 @@ type AnyZodTypeDef = z.ZodTypeDef & { typeName: ZodTypeName };
6262
6363type AnyZodArrayDef = z . ZodArrayDef & { type : z . AnyZodObject } ;
6464
65+ function isZodObject ( value : unknown ) : value is z . AnyZodObject {
66+ return isPlainObject ( value ) ;
67+ }
68+
6569function isZodTypeDef ( value : unknown ) : value is AnyZodTypeDef {
6670 return isPlainObject ( value ) && ZOD_TYPE_NAMES . includes ( value . typeName as ZodTypeName ) ;
6771}
@@ -424,7 +428,11 @@ function generateSampleData({
424428export function createUploadTemplateCSV ( instrument : AnyUnilingualFormInstrument ) {
425429 // TODO - type validationSchema as object
426430 try {
427- const instrumentSchema = instrument . validationSchema as z . AnyZodObject ;
431+ //This needs to be tested!!!
432+ if ( ! isZodObject ( instrument . validationSchema ) ) {
433+ throw new Error ( 'Error in validation schema type' ) ;
434+ }
435+ const instrumentSchema = instrument . validationSchema ;
428436
429437 const instrumentSchemaDef : unknown = instrument . validationSchema . _def ;
430438
You can’t perform that action at this time.
0 commit comments