Skip to content

Commit d23f3c0

Browse files
committed
Add validation level for same ID forms
1 parent f93a3f9 commit d23f3c0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

backend/routes/forms/new.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,10 @@ async def post(self, request: Request) -> JSONResponse:
2626
except ValidationError as e:
2727
return JSONResponse(e.errors())
2828

29+
if await request.state.db.forms.find_one({"_id": form.id}):
30+
return JSONResponse({
31+
"error": "Form with same ID already exists."
32+
})
33+
2934
await request.state.db.forms.insert_one(form.dict(by_alias=True))
3035
return JSONResponse(form.dict())

0 commit comments

Comments
 (0)