package mtsar.api.validation;

import io.dropwizard.validation.ValidationMethod;
import mtsar.api.Answer;
import mtsar.api.Task;
import org.apache.commons.lang3.ArrayUtils;

public class TaskAnswerValidation {
    private final Task task;
    private final Answer answer;

    public TaskAnswerValidation(Task task, Answer answer) {
        this.task = task;
        this.answer = answer;
    }

    @ValidationMethod(message="task type 'single' requires one answer")
    public boolean isAnswerPresentForTypeSingle() {
        return !task.getType().equalsIgnoreCase("single") || ArrayUtils.getLength(answer.getAnswers()) == 1;
    }
}

@@ -422,10 +422,36 @@
 sage
-=%22
+ = %22#task-single-no-answer: 
 task
@@ -654,10 +654,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

Add parsable IDs to validation errors [ci skip]