Pydantic
satya - 3/3/2024, 4:25:02 PM
The BaseModel methods and properties
satya - 3/3/2024, 4:51:22 PM
Pydantic lecture video
satya - 3/3/2024, 5:55:00 PM
Here are some out of the box types
satya - 3/3/2024, 5:57:28 PM
you have to first do
pip install pydantic
satya - 3/3/2024, 5:57:46 PM
Set 1
from pydantic import (
BaseModel,
constr,
conint,
confloat,
conlist,
condecimal,
EmailStr,
UrlStr,
Json,
SecretStr,
SecretBytes,
IPv4Address,
IPv6Address,
FilePath,
DirectoryPath,
Path,
PositiveInt,
NegativeInt,
PositiveFloat,
NegativeFloat,
StrictStr,
StrictBool,
StrictInt,
StrictFloat,
)
satya - 3/3/2024, 5:58:02 PM
set 2
from pydantic.types import UUID1, UUID3, UUID4, UUID5
from pydantic.networks import IPv4Address, IPv6Address, IPvAnyAddress
satya - 3/3/2024, 6:00:20 PM
The types are somewhat documented here
satya - 3/3/2024, 6:02:10 PM
For EmailStr you have to do this
pip install email-validator
satya - 3/3/2024, 6:16:12 PM
Here is how to use annotated validators
satya - 3/3/2024, 8:35:57 PM
Here are various ways to constrain fields including annotated
Here are various ways to constrain fields including annotated
satya - 3/4/2024, 11:36:45 AM
Field validators are documented here