Skip to content

Commit a13ec7c

Browse files
committed
update
1 parent 09e61cd commit a13ec7c

File tree

1 file changed

+27
-18
lines changed
  • packages/orm/src/client/crud/validator

1 file changed

+27
-18
lines changed

packages/orm/src/client/crud/validator/index.ts

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,18 @@ export class InputValidator<Schema extends SchemaDef> {
745745
where: z.lazy(() => this.makeWhereSchema(fieldDef.type, false)).optional(),
746746
}
747747
: {}),
748-
select: z.lazy(() => this.makeSelectSchema(fieldDef.type)).optional(),
749-
include: z.lazy(() => this.makeIncludeSchema(fieldDef.type)).optional(),
750-
omit: z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional(),
748+
select: z
749+
.lazy(() => this.makeSelectSchema(fieldDef.type))
750+
.optional()
751+
.nullable(),
752+
include: z
753+
.lazy(() => this.makeIncludeSchema(fieldDef.type))
754+
.optional()
755+
.nullable(),
756+
omit: z
757+
.lazy(() => this.makeOmitSchema(fieldDef.type))
758+
.optional()
759+
.nullable(),
751760
...(fieldDef.array
752761
? {
753762
// to-many relations can be ordered, skipped, taken, and cursor-located
@@ -864,9 +873,9 @@ export class InputValidator<Schema extends SchemaDef> {
864873
const dataSchema = this.makeCreateDataSchema(model, false);
865874
let schema: ZodType = z.strictObject({
866875
data: dataSchema,
867-
select: this.makeSelectSchema(model).optional(),
868-
include: this.makeIncludeSchema(model).optional(),
869-
omit: this.makeOmitSchema(model).optional(),
876+
select: this.makeSelectSchema(model).optional().nullable(),
877+
include: this.makeIncludeSchema(model).optional().nullable(),
878+
omit: this.makeOmitSchema(model).optional().nullable(),
870879
});
871880
schema = this.refineForSelectIncludeMutuallyExclusive(schema);
872881
schema = this.refineForSelectOmitMutuallyExclusive(schema);
@@ -880,8 +889,8 @@ export class InputValidator<Schema extends SchemaDef> {
880889
private makeCreateManyAndReturnSchema(model: string) {
881890
const base = this.makeCreateManyDataSchema(model, []);
882891
const result = base.extend({
883-
select: this.makeSelectSchema(model).optional(),
884-
omit: this.makeOmitSchema(model).optional(),
892+
select: this.makeSelectSchema(model).optional().nullable(),
893+
omit: this.makeOmitSchema(model).optional().nullable(),
885894
});
886895
return this.refineForSelectOmitMutuallyExclusive(result).optional();
887896
}
@@ -1142,9 +1151,9 @@ export class InputValidator<Schema extends SchemaDef> {
11421151
let schema: ZodType = z.strictObject({
11431152
where: this.makeWhereSchema(model, true),
11441153
data: this.makeUpdateDataSchema(model),
1145-
select: this.makeSelectSchema(model).optional(),
1146-
include: this.makeIncludeSchema(model).optional(),
1147-
omit: this.makeOmitSchema(model).optional(),
1154+
select: this.makeSelectSchema(model).optional().nullable(),
1155+
include: this.makeIncludeSchema(model).optional().nullable(),
1156+
omit: this.makeOmitSchema(model).optional().nullable(),
11481157
});
11491158
schema = this.refineForSelectIncludeMutuallyExclusive(schema);
11501159
schema = this.refineForSelectOmitMutuallyExclusive(schema);
@@ -1162,8 +1171,8 @@ export class InputValidator<Schema extends SchemaDef> {
11621171
private makeUpdateManyAndReturnSchema(model: string) {
11631172
const base = this.makeUpdateManySchema(model);
11641173
let schema: ZodType = base.extend({
1165-
select: this.makeSelectSchema(model).optional(),
1166-
omit: this.makeOmitSchema(model).optional(),
1174+
select: this.makeSelectSchema(model).optional().nullable(),
1175+
omit: this.makeOmitSchema(model).optional().nullable(),
11671176
});
11681177
schema = this.refineForSelectOmitMutuallyExclusive(schema);
11691178
return schema;
@@ -1174,9 +1183,9 @@ export class InputValidator<Schema extends SchemaDef> {
11741183
where: this.makeWhereSchema(model, true),
11751184
create: this.makeCreateDataSchema(model, false),
11761185
update: this.makeUpdateDataSchema(model),
1177-
select: this.makeSelectSchema(model).optional(),
1178-
include: this.makeIncludeSchema(model).optional(),
1179-
omit: this.makeOmitSchema(model).optional(),
1186+
select: this.makeSelectSchema(model).optional().nullable(),
1187+
include: this.makeIncludeSchema(model).optional().nullable(),
1188+
omit: this.makeOmitSchema(model).optional().nullable(),
11801189
});
11811190
schema = this.refineForSelectIncludeMutuallyExclusive(schema);
11821191
schema = this.refineForSelectOmitMutuallyExclusive(schema);
@@ -1291,8 +1300,8 @@ export class InputValidator<Schema extends SchemaDef> {
12911300
private makeDeleteSchema(model: GetModels<Schema>) {
12921301
let schema: ZodType = z.strictObject({
12931302
where: this.makeWhereSchema(model, true),
1294-
select: this.makeSelectSchema(model).optional(),
1295-
include: this.makeIncludeSchema(model).optional(),
1303+
select: this.makeSelectSchema(model).optional().nullable(),
1304+
include: this.makeIncludeSchema(model).optional().nullable(),
12961305
});
12971306
schema = this.refineForSelectIncludeMutuallyExclusive(schema);
12981307
schema = this.refineForSelectOmitMutuallyExclusive(schema);

0 commit comments

Comments
 (0)