from pydantic_choices import choice
import pydantic as pd
Licenses = choice(["GPL", "GPLv3+", "MIT", "MPL 2.0"])
class Project(pd.BaseModel):
id: str
url: str
license: Licenses
# Validation passes
Project(
id="pydantic_choices",
url="https://github.com/vinissimus/pydantic-choices",
license="MIT",
)
# Validation fails
p1 = Project(
id="pydantic_choices",
url="https://github.com/vinissimus/pydantic-choices",
license="propietary", # value not in choice
)
-
Notifications
You must be signed in to change notification settings - Fork 0
License
vinissimus/pydantic-choices
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published