diff --git a/src/controllers/SurveyController.ts b/src/controllers/SurveyController.ts index 848ed06..4e71575 100644 --- a/src/controllers/SurveyController.ts +++ b/src/controllers/SurveyController.ts @@ -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);