1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-21 21:09:22 +00:00

Avoid creation of duplicate entries

This commit is contained in:
Pierre HUBERT 2020-05-18 13:23:46 +02:00
parent d38da1117f
commit e19864f3f4

View File

@ -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);