File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
packages/convex-helpers/server Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -827,6 +827,10 @@ test("convexToZod complex types", () => {
827827
828828 const unionValidator = convexToZod ( v . union ( v . string ( ) , v . number ( ) ) ) ;
829829 expect ( unionValidator . constructor . name ) . toBe ( "ZodUnion" ) ;
830+ expect ( unionValidator . options [ 0 ] . constructor . name ) . toBe ( "ZodString" ) ;
831+ expect ( unionValidator . options [ 1 ] . constructor . name ) . toBe ( "ZodNumber" ) ;
832+ expectTypeOf ( unionValidator . options [ 0 ] ) . toEqualTypeOf < z . ZodString > ( ) ;
833+ expectTypeOf ( unionValidator . options [ 1 ] ) . toEqualTypeOf < z . ZodNumber > ( ) ;
830834
831835 const literalValidator = convexToZod ( v . literal ( "hi" ) ) ;
832836 expect ( literalValidator . constructor . name ) . toBe ( "ZodLiteral" ) ;
Original file line number Diff line number Diff line change @@ -1364,9 +1364,26 @@ type ZodFromValidatorBase<V extends GenericValidator> =
13641364 : z . ZodRecord < z . ZodString , ZodValidatorFromConvex < Value > >
13651365 : V extends VArray < any , any >
13661366 ? z . ZodArray < ZodValidatorFromConvex < V [ "element" ] > >
1367- : V extends VUnion < any , any , any , any >
1367+ : V extends VUnion <
1368+ any ,
1369+ [
1370+ infer A extends GenericValidator ,
1371+ infer B extends GenericValidator ,
1372+ ...infer Rest extends GenericValidator [ ] ,
1373+ ] ,
1374+ any ,
1375+ any
1376+ >
13681377 ? z . ZodUnion <
1369- [ ZodValidatorFromConvex < V [ "members" ] [ number ] > ]
1378+ [
1379+ ZodValidatorFromConvex < A > ,
1380+ ZodValidatorFromConvex < B > ,
1381+ ...{
1382+ [ K in keyof Rest ] : ZodValidatorFromConvex <
1383+ Rest [ K ]
1384+ > ;
1385+ } ,
1386+ ]
13701387 >
13711388 : z . ZodTypeAny ; // fallback for unknown validators
13721389
You can’t perform that action at this time.
0 commit comments