AskReference
DefinitionIntroductory

What does the '...' argument mean in Field(..., min_length=2)?

The '...' argument in Field(..., min_length=2) means that the field is required and there is no default value. In this context, it marks the 'name' field as mandatory, so validation fails if the field is omitted or empty.

Key points

  • '...' signals that a value is required for that field.
  • It indicates there is no default value assigned to the field.
  • Validation will raise an error if the required value is missing or invalid.
Source:FastAPI: Modern Python Web Development· Pydantic, Type Hints, and Models Tour· p. 79–93

Related questions

Cover of FastAPI: Modern Python Web Development

FastAPI: Modern Python Web Development

Bill Lubanovic;

First Edition · O'Reilly Media, Inc.

View this ebook