@@ -60,6 +60,8 @@ type UploadOperationResult<T> =
6060
6161type AnyZodTypeDef = z . ZodTypeDef & { typeName : ZodTypeName } ;
6262
63+ type AnyZodArrayDef = z . ZodArrayDef & { type : z . AnyZodObject } ;
64+
6365function isZodTypeDef ( value : unknown ) : value is AnyZodTypeDef {
6466 return isPlainObject ( value ) && ZOD_TYPE_NAMES . includes ( value . typeName as ZodTypeName ) ;
6567}
@@ -76,7 +78,7 @@ function isZodSetDef(def: AnyZodTypeDef): def is z.ZodSetDef {
7678 return def . typeName === z . ZodFirstPartyTypeKind . ZodSet ;
7779}
7880
79- function isZodArrayDef ( def : AnyZodTypeDef ) : def is z . ZodArrayDef {
81+ function isZodArrayDef ( def : AnyZodTypeDef ) : def is AnyZodArrayDef {
8082 return def . typeName === z . ZodFirstPartyTypeKind . ZodArray ;
8183}
8284
@@ -196,8 +198,7 @@ export function interpretZodArray(
196198 ) ;
197199 }
198200
199- // TODO - check zod array inner type is object
200- const shape = ( def . type as z . AnyZodObject ) . shape as { [ key : string ] : z . ZodTypeAny } ;
201+ const shape = def . type . shape as { [ key : string ] : z . ZodTypeAny } ;
201202
202203 for ( const [ key , insideType ] of Object . entries ( shape ) ) {
203204 const def : unknown = insideType . _def ;
@@ -257,7 +258,10 @@ export function interpretZodValue(
257258 case 'ZodSet' :
258259 if ( entry . startsWith ( 'SET(' ) ) {
259260 const setData = extractSetEntry ( entry ) ;
260- const values = setData . split ( ',' ) . map ( ( s ) => s . trim ( ) ) . filter ( Boolean ) ;
261+ const values = setData
262+ . split ( ',' )
263+ . map ( ( s ) => s . trim ( ) )
264+ . filter ( Boolean ) ;
261265 if ( values . length === 0 ) {
262266 return { message : 'Empty set is not allowed' , success : false } ;
263267 }
@@ -303,6 +307,10 @@ export function interpretZodObjectValue(
303307 }
304308 for ( let i = 0 ; i < record . length ; i ++ ) {
305309 // TODO - make sure this is defined
310+ if ( ! record [ i ] ) {
311+ return { message : `Failed to interpret field '${ i } '` , success : false } ;
312+ }
313+
306314 const recordValue = record [ i ] ! . split ( ':' ) [ 1 ] ! . trim ( ) ;
307315
308316 const zListResult = zList [ i ] ! ;
0 commit comments