Logo OneBite.dev

AI stuff for devs, one bite at a time

How to add multiple types in pydantic

To allow pydantic to accept multiple values we can use Union

To allow pydantic to accept multiple values we can use Union and put the values inside the square brackets

For example:

favicon_link: Union[str, bool]

This way we allow favicon_link to be any str or bool

python