Pydantic
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
Pydantic-i i validon të dhënat sipas type hints: e përshkruan formën me një klasë BaseModel dhe ai kontrollon dhe konverton vetë JSON-in që vjen. FastAPI-ja ndërtohet mbi të.
EnglishEN
Pydantic validates data using type hints: you describe the shape with a BaseModel class and it checks and converts incoming JSON itself. FastAPI is built on it.
Si ta mendosh
Si roja te dera që e kontrollon vërtet çdo biletë.
Lexoje në anglisht
Like a doorman who actually checks every ticket.
Shembull kodipython
from pydantic import BaseModel
class Termi(BaseModel):
id: str
nota: int
Termi.model_validate({"id": "api", "nota": "5"}) # "5" → 5