Enums & validated models

P28.protocols-abcs.02 · Audience: guest, it-ml, language-pro · Prerequisites: Protocols vs ABCs

Real LLM grading for this pageLLM grading (this page):

Two everyday data-modelling patterns close out the pillar. An enum replaces a scatter of magic strings with a small, closed set of named members — safer, self-documenting, and impossible to mistype. A validated model applies the "parse, don't just store" principle: data is checked and normalised at the boundary, so the rest of your program only ever sees valid values (the idea behind libraries like pydantic).

Ask the mentor about this module

Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.

Images, PDF or text. Kept on this device only.
Keeping your files on this device

Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.

Ctrl/Cmd + Enter to send
Rung 1 — model states with an Enum

Loading exercise…

Rung 2 — a validated value object

Loading exercise…

My notes on this module

Loading your notes...

Enums & validated models — TransformerLab