🐛 Fix non-required field poll validate incorrect

This commit is contained in:
2025-08-12 17:48:03 +08:00
parent 58e34b20e1
commit 96cceafe77
2 changed files with 5 additions and 3 deletions

View File

@@ -75,6 +75,8 @@ public class PollService(AppDatabase db, ICacheService cache)
var questionId = question.Id.ToString();
if (question.IsRequired && !answer.ContainsKey(questionId))
throw new Exception($"Missing required field: {question.Title}");
else if (!answer.ContainsKey(questionId))
continue;
switch (question.Type)
{
case PollQuestionType.Rating when answer[questionId].ValueKind != JsonValueKind.Number: