mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-19 16:15:16 +00:00
Avoid creation of duplicate entries
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user