@@ -627,30 +627,32 @@ export class InputValidator<Schema extends SchemaDef> {
627627 }
628628
629629 private makeRelationSelectIncludeSchema ( fieldDef : FieldDef ) {
630- return z . union ( [
631- z . boolean ( ) ,
632- z . strictObject ( {
633- ...( fieldDef . array || fieldDef . optional
634- ? {
635- // to-many relations and optional to-one relations are filterable
636- where : z . lazy ( ( ) => this . makeWhereSchema ( fieldDef . type , false ) ) . optional ( ) ,
637- }
638- : { } ) ,
639- select : z . lazy ( ( ) => this . makeSelectSchema ( fieldDef . type ) ) . optional ( ) ,
640- include : z . lazy ( ( ) => this . makeIncludeSchema ( fieldDef . type ) ) . optional ( ) ,
641- omit : z . lazy ( ( ) => this . makeOmitSchema ( fieldDef . type ) ) . optional ( ) ,
642- ...( fieldDef . array
643- ? {
644- // to-many relations can be ordered, skipped, taken, and cursor-located
645- orderBy : z . lazy ( ( ) => this . makeOrderBySchema ( fieldDef . type , true , false ) ) . optional ( ) ,
646- skip : this . makeSkipSchema ( ) . optional ( ) ,
647- take : this . makeTakeSchema ( ) . optional ( ) ,
648- cursor : this . makeCursorSchema ( fieldDef . type ) . optional ( ) ,
649- distinct : this . makeDistinctSchema ( fieldDef . type ) . optional ( ) ,
650- }
651- : { } ) ,
652- } ) ,
653- ] ) ;
630+ let objSchema : z . ZodType = z . strictObject ( {
631+ ...( fieldDef . array || fieldDef . optional
632+ ? {
633+ // to-many relations and optional to-one relations are filterable
634+ where : z . lazy ( ( ) => this . makeWhereSchema ( fieldDef . type , false ) ) . optional ( ) ,
635+ }
636+ : { } ) ,
637+ select : z . lazy ( ( ) => this . makeSelectSchema ( fieldDef . type ) ) . optional ( ) ,
638+ include : z . lazy ( ( ) => this . makeIncludeSchema ( fieldDef . type ) ) . optional ( ) ,
639+ omit : z . lazy ( ( ) => this . makeOmitSchema ( fieldDef . type ) ) . optional ( ) ,
640+ ...( fieldDef . array
641+ ? {
642+ // to-many relations can be ordered, skipped, taken, and cursor-located
643+ orderBy : z . lazy ( ( ) => this . makeOrderBySchema ( fieldDef . type , true , false ) ) . optional ( ) ,
644+ skip : this . makeSkipSchema ( ) . optional ( ) ,
645+ take : this . makeTakeSchema ( ) . optional ( ) ,
646+ cursor : this . makeCursorSchema ( fieldDef . type ) . optional ( ) ,
647+ distinct : this . makeDistinctSchema ( fieldDef . type ) . optional ( ) ,
648+ }
649+ : { } ) ,
650+ } ) ;
651+
652+ objSchema = this . refineForSelectIncludeMutuallyExclusive ( objSchema ) ;
653+ objSchema = this . refineForSelectOmitMutuallyExclusive ( objSchema ) ;
654+
655+ return z . union ( [ z . boolean ( ) , objSchema ] ) ;
654656 }
655657
656658 private makeOmitSchema ( model : string ) {
@@ -742,7 +744,7 @@ export class InputValidator<Schema extends SchemaDef> {
742744
743745 private makeCreateSchema ( model : string ) {
744746 const dataSchema = this . makeCreateDataSchema ( model , false ) ;
745- const schema = z . object ( {
747+ const schema = z . strictObject ( {
746748 data : dataSchema ,
747749 select : this . makeSelectSchema ( model ) . optional ( ) ,
748750 include : this . makeIncludeSchema ( model ) . optional ( ) ,
@@ -757,12 +759,10 @@ export class InputValidator<Schema extends SchemaDef> {
757759
758760 private makeCreateManyAndReturnSchema ( model : string ) {
759761 const base = this . makeCreateManyDataSchema ( model , [ ] ) ;
760- const result = base . merge (
761- z . strictObject ( {
762- select : this . makeSelectSchema ( model ) . optional ( ) ,
763- omit : this . makeOmitSchema ( model ) . optional ( ) ,
764- } ) ,
765- ) ;
762+ const result = base . extend ( {
763+ select : this . makeSelectSchema ( model ) . optional ( ) ,
764+ omit : this . makeOmitSchema ( model ) . optional ( ) ,
765+ } ) ;
766766 return this . refineForSelectOmitMutuallyExclusive ( result ) . optional ( ) ;
767767 }
768768
@@ -986,7 +986,7 @@ export class InputValidator<Schema extends SchemaDef> {
986986 const whereSchema = this . makeWhereSchema ( model , true ) ;
987987 const createSchema = this . makeCreateDataSchema ( model , false , withoutFields ) ;
988988 return this . orArray (
989- z . object ( {
989+ z . strictObject ( {
990990 where : whereSchema ,
991991 create : createSchema ,
992992 } ) ,
@@ -995,7 +995,7 @@ export class InputValidator<Schema extends SchemaDef> {
995995 }
996996
997997 private makeCreateManyDataSchema ( model : string , withoutFields : string [ ] ) {
998- return z . object ( {
998+ return z . strictObject ( {
999999 data : this . makeCreateDataSchema ( model , true , withoutFields , true ) ,
10001000 skipDuplicates : z . boolean ( ) . optional ( ) ,
10011001 } ) ;
@@ -1006,7 +1006,7 @@ export class InputValidator<Schema extends SchemaDef> {
10061006 // #region Update
10071007
10081008 private makeUpdateSchema ( model : string ) {
1009- const schema = z . object ( {
1009+ const schema = z . strictObject ( {
10101010 where : this . makeWhereSchema ( model , true ) ,
10111011 data : this . makeUpdateDataSchema ( model ) ,
10121012 select : this . makeSelectSchema ( model ) . optional ( ) ,
@@ -1017,7 +1017,7 @@ export class InputValidator<Schema extends SchemaDef> {
10171017 }
10181018
10191019 private makeUpdateManySchema ( model : string ) {
1020- return z . object ( {
1020+ return z . strictObject ( {
10211021 where : this . makeWhereSchema ( model , false ) . optional ( ) ,
10221022 data : this . makeUpdateDataSchema ( model , [ ] , true ) ,
10231023 limit : z . int ( ) . nonnegative ( ) . optional ( ) ,
@@ -1026,17 +1026,15 @@ export class InputValidator<Schema extends SchemaDef> {
10261026
10271027 private makeUpdateManyAndReturnSchema ( model : string ) {
10281028 const base = this . makeUpdateManySchema ( model ) ;
1029- const result = base . merge (
1030- z . strictObject ( {
1031- select : this . makeSelectSchema ( model ) . optional ( ) ,
1032- omit : this . makeOmitSchema ( model ) . optional ( ) ,
1033- } ) ,
1034- ) ;
1029+ const result = base . extend ( {
1030+ select : this . makeSelectSchema ( model ) . optional ( ) ,
1031+ omit : this . makeOmitSchema ( model ) . optional ( ) ,
1032+ } ) ;
10351033 return this . refineForSelectOmitMutuallyExclusive ( result ) ;
10361034 }
10371035
10381036 private makeUpsertSchema ( model : string ) {
1039- const schema = z . object ( {
1037+ const schema = z . strictObject ( {
10401038 where : this . makeWhereSchema ( model , true ) ,
10411039 create : this . makeCreateDataSchema ( model , false ) ,
10421040 update : this . makeUpdateDataSchema ( model ) ,
@@ -1148,7 +1146,7 @@ export class InputValidator<Schema extends SchemaDef> {
11481146 // #region Delete
11491147
11501148 private makeDeleteSchema ( model : GetModels < Schema > ) {
1151- const schema = z . object ( {
1149+ const schema = z . strictObject ( {
11521150 where : this . makeWhereSchema ( model , true ) ,
11531151 select : this . makeSelectSchema ( model ) . optional ( ) ,
11541152 include : this . makeIncludeSchema ( model ) . optional ( ) ,
@@ -1187,7 +1185,7 @@ export class InputValidator<Schema extends SchemaDef> {
11871185 const modelDef = requireModel ( this . schema , model ) ;
11881186 return z . union ( [
11891187 z . literal ( true ) ,
1190- z . object ( {
1188+ z . strictObject ( {
11911189 _all : z . literal ( true ) . optional ( ) ,
11921190 ...Object . keys ( modelDef . fields ) . reduce (
11931191 ( acc , field ) => {
@@ -1257,7 +1255,7 @@ export class InputValidator<Schema extends SchemaDef> {
12571255 const modelDef = requireModel ( this . schema , model ) ;
12581256 const nonRelationFields = Object . keys ( modelDef . fields ) . filter ( ( field ) => ! modelDef . fields [ field ] ?. relation ) ;
12591257
1260- let schema = z . object ( {
1258+ let schema = z . strictObject ( {
12611259 where : this . makeWhereSchema ( model , false ) . optional ( ) ,
12621260 orderBy : this . orArray ( this . makeOrderBySchema ( model , false , true ) , true ) . optional ( ) ,
12631261 by : this . orArray ( z . enum ( nonRelationFields ) , true ) ,
0 commit comments