Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 1.07 KB

README.md

File metadata and controls

35 lines (24 loc) · 1.07 KB

Pydantic-Choices

Build Status PyPI version Codcov

How to use

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
)