Skip to content
Discussion options

You must be logged in to vote

The example above doesn't work in current version.
But the following example works:

from typing import Annotated

from fastapi import FastAPI, Query
from pydantic import Field

app = FastAPI()

# define alias for list single item length constraints
ListItemLength = Annotated[str, Field(min_length=5, max_length=10)]


@app.get("/test")
async def test(
    query: Annotated[list[ListItemLength], Query(min_length=2, max_length=3)],
):
    return query

Replies: 7 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@sinisaos
Comment options

@YuriiMotov
Comment options

Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
7 participants
Converted from issue

This discussion was converted from issue #1629 on February 28, 2023 18:39.