Allow document to be dragged to the top of a collection (#4489)

This commit is contained in:
Apoorv Mishra
2022-11-28 19:12:58 +05:30
committed by GitHub
parent cc333637dd
commit d09c583c72
2 changed files with 17 additions and 2 deletions

View File

@@ -208,7 +208,7 @@ export const DocumentsMoveSchema = BaseIdSchema.extend({
parentDocumentId: z.string().uuid().optional(),
/** Helps evaluate the new index in collection structure upon move */
index: z.number().positive().optional(),
index: z.number().gte(0).optional(),
}).refine((obj) => !(obj.parentDocumentId === obj.id), {
message: "infinite loop detected, cannot nest a document inside itself",
});