Skip to content

Show invalid message for select fields#360

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

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

Conversation

@elio2t
Copy link
Copy Markdown

@elio2t elio2t commented Oct 17, 2024

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
Copy link
Copy Markdown

codecov bot commented Oct 17, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

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