Skip to content

Commit 80da898

Browse files
author
PatrikKozak
committed
fix: adds draftsEnabled to baseSchema for tabs / arrays / groups & allows for null enum
1 parent b4f39d5 commit 80da898

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/mongoose/buildSchema.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
308308
id: false,
309309
},
310310
disableUnique: buildSchemaOptions.disableUnique,
311+
draftsEnabled: buildSchemaOptions.draftsEnabled,
311312
},
312313
),
313314
};
@@ -336,6 +337,7 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
336337
options: { _id: false, id: false },
337338
allowIDField: true,
338339
disableUnique: buildSchemaOptions.disableUnique,
340+
draftsEnabled: buildSchemaOptions.draftsEnabled,
339341
},
340342
)],
341343
};
@@ -358,6 +360,7 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
358360
id: false,
359361
},
360362
disableUnique: buildSchemaOptions.disableUnique,
363+
draftsEnabled: buildSchemaOptions.draftsEnabled,
361364
},
362365
),
363366
};
@@ -376,6 +379,10 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
376379
}),
377380
};
378381

382+
if (buildSchemaOptions.draftsEnabled || !field.required) {
383+
baseSchema.enum.push(null);
384+
}
385+
379386
schema.add({
380387
[field.name]: localizeSchema(
381388
field,

0 commit comments

Comments
 (0)