from typing import Literal from pydantic import BaseModel from .form_base_question import FormBaseQuestion from fiber_package.signup.enums import FormElementCategory from fiber_package.signup.answer.answer_open_questions import AnswerOpenQuestions class OpenQuestion(BaseModel): question_en: str question_nl: str explanation_en: str explanation_nl: str placeholder_en: str = "" placeholder_nl: str = "" class FormOpenQuestions(FormBaseQuestion): category: Literal[FormElementCategory.open_questions] questions: list[OpenQuestion] def validate_answer(self, answer: AnswerOpenQuestions) -> None: if answer.question_name != self.name: raise ValueError("Answer question name does not match.") answer_list = answer.answer_list if len(answer_list) != len(self.questions): raise ValueError("Length of answer question list does not match.")