Skip to content
This repository was archived by the owner on Jun 7, 2026. It is now read-only.

Show invalid message for select fields#360

Open
elio2t wants to merge 1 commit into
pydantic:mainfrom
elio2t:fix/invalid-select
Open

Show invalid message for select fields#360
elio2t wants to merge 1 commit into
pydantic:mainfrom
elio2t:fix/invalid-select

Conversation

@elio2t

@elio2t elio2t commented Oct 17, 2024

Copy link
Copy Markdown

Fixes #270

It can be useful to display invalid messages for select fields when their validation depends on another field.

Before:
Screenshot 2024-10-17 at 15 23 44

After:
Screenshot 2024-10-17 at 15 11 29

For this error 422:

{
    "detail": {
        "form": [
            {
                "type": "text",
                "loc": [
                    "text_field"
                ],
                "msg": "Text field error"
            },
            {
                "type": "select",
                "loc": [
                    "select_single"
                ],
                "msg": "Select field error"
            }
        ]
    }
}

We could go further and display the border in red like the text field, but that doesn't seem trivial.

@codecov

codecov Bot commented Oct 17, 2024

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select form does not show PydanticCustomError on page

1 participant