File size: 1,065 Bytes
a3847b2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | """
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]
|