Top "Pydantic" questions

Pydantic is a library for data validation and settings management based on Python type hinting and variable annotations.

How to parse list of models with Pydantic

I use Pydantic to model the requests and responses to an API. I defined a User class: from pydantic import …

python pydantic
Pydantic: Make field None in validator based on other field's value

I'm using the pydantic BaseModel with a validator like this: from datetime import date from typing import List, Optional from …

python pydantic
Python/Pydantic - using a list with json objects

I have a working model to receive a json data set using pydantic. The model data set looks like this: …

python json pydantic
fastapi form data with pydantic model

I am trying to submit data from html forms and on the validate it with pydantic model. Using this code …

python fastapi pydantic
FastAPI: how to read body as any valid json?

Sorry, not proficient in Python. I haven't found the docs for that use case. How can I get the request …

json fastapi pydantic
pydantic generate model from dict

I've only recently starting glansing over the documentation of pydantic but I don't see a straight-forward approach to generating models …

python pydantic
Read a body JSON list with FastAPI

The body of an HTTP PUT request is a JSON list - like this: [item1, item2, item3, ...] I can't change …

python fastapi pydantic
Python Pydantic - how to have an "optional" field but if present required to conform to not None value?

I am trying to validate an object that has "optional" fields in the sense that they may or may not …

python python-3.x pydantic
Why do I get "AttributeError: __fields_set__" when subclassing a Pydantic BaseModel?

I have this project where my base class and my sub-classes implement pydantic.BaseModel: from pydantic import BaseModel from typing …

python pydantic