mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-12-25 13:08:51 +00:00
Avoid creation of duplicate entries
This commit is contained in:
parent
d38da1117f
commit
e19864f3f4
@ -59,6 +59,10 @@ export class SurveyController {
|
||||
if(!survey.allowNewChoices)
|
||||
h.error(401, "It is not possible to create new choices for this survey!");
|
||||
|
||||
// Check if we are not creating a duplicate
|
||||
if(survey.choices.find((c) => c.name.toLowerCase() == newChoice.toLowerCase()) != undefined)
|
||||
h.error(401, "This choice already exists!");
|
||||
|
||||
// Create the choice
|
||||
await SurveyHelper.CreateChoice(surveyID, newChoice);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user