Skip to content

How to factorize examples? #9172

Answered by uriyyo
bfontaine asked this question in Question
Apr 5, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

It's should be possible to use field on annotated level:

MyID = Annotated[
    str,
    StringConstraints(pattern=r"^ABC\d{3}$"),
    Field(examples=["ABC123"]),
]


class Foo(BaseModel):
    id: MyID


class Bar(BaseModel):
    foo_id: MyID

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bfontaine
Comment options

Answer selected by bfontaine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants