Field Rules: Lengths, Ranges and Choices

Field() puts rules on a model's fields, such as a name of 1 to 80 characters and an age of 18 or over, Literal allows only a fixed set of values, EmailStr checks the shape of an email address, and Query puts the same kind of rules on a query parameter.

By

Updated

Cheat sheet: Field Rules: Lengths, Ranges and Choices
Category
FastAPI
Level
Journeyman
Tags
Annotated, EmailStr, fastapi, Field Validation, Literal Type (python), python, Query Parameter (fastapi)