| """ |
| Pydantic models for the static JSON data files. |
| """ |
| from pydantic import BaseModel, field_validator |
|
|
|
|
| class TongueTwister(BaseModel): |
| text: str |
| focus: str |
|
|
|
|
| class TTLevels(BaseModel): |
| easy: list[TongueTwister] |
| medium: list[TongueTwister] |
| hard: list[TongueTwister] |
|
|
|
|
| class ImpCategory(BaseModel): |
| category: str |
| questions: list[str] |
|
|
| @field_validator("questions") |
| @classmethod |
| def questions_not_empty(cls, v: list[str]) -> list[str]: |
| if not v: |
| raise ValueError("questions list must not be empty") |
| return v |
|
|
|
|
| class IvCategory(BaseModel): |
| category: str |
| questions: list[str] |
|
|
| @field_validator("questions") |
| @classmethod |
| def questions_not_empty(cls, v: list[str]) -> list[str]: |
| if not v: |
| raise ValueError("questions list must not be empty") |
| return v |
|
|
|
|
| class AppData(BaseModel): |
| """Container holding all loaded JSON data (validated at startup).""" |
| jam: list[str] |
| tt: TTLevels |
| impromptu: list[ImpCategory] |
| interview: list[IvCategory] |
|
|