← All notes

Pydantic models and validators: model_validate, model_dump and field_validator

Answer: A Pydantic model validates input when you create it; a ValidationError is raised when data cannot be successfully parsed into a model instance.

Core methods

Validators

In FastAPI

FastAPI uses Pydantic models to declare a request body. Invalid data gets a clear error indicating where and what the incorrect data was.

The JSON Schema of the model is part of the generated OpenAPI schema.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: pydantic/pydantic (GitHub), Models (Pydantic docs), MIT (https://raw.githubusercontent.com/pydantic/pydantic/main/LICENSE). Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors; pydantic/pydantic (GitHub), Validators (Pydantic docs), MIT (https://raw.githubusercontent.com/pydantic/pydantic/main/LICENSE). Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors; fastapi/fastapi (GitHub), Request Body (FastAPI docs), MIT (https://raw.githubusercontent.com/fastapi/fastapi/master/LICENSE). Copyright (c) 2018 Sebastián Ramírez. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: pydantic/pydantic (GitHub), Models (Pydantic docs), MIT (https://raw.githubusercontent.com/pydantic/pydantic/main/LICENSE). Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors; pydantic/pydantic (GitHub), Validators (Pydantic docs), MIT (https://raw.githubusercontent.com/pydantic/pydantic/main/LICENSE). Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors; fastapi/fastapi (GitHub), Request Body (FastAPI docs), MIT (https://raw.githubusercontent.com/fastapi/fastapi/master/LICENSE). Copyright (c) 2018 Sebastián Ramírez.

Cite this

Permanent ID: iil:note:60a5wh0j

iinventedlight. 2026. "Pydantic models and validators: model_validate, model_dump and field_validator." iinventedlight Library, iil:note:60a5wh0j, version of 2026-11-16. https://iinventedlight.com/library/notes/pydantic-models-and-validators/. License: CC-BY-4.0.

@misc{iil_note_60a5wh0j,
  author = {{iinventedlight}},
  title = {{Pydantic models and validators: model\_validate, model\_dump and field\_validator}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/pydantic-models-and-validators/},
  note = {Permanent ID iil:note:60a5wh0j. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/pydantic-models-and-validators.md.