Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show invalid message for select fields #360

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

elio2t
Copy link

@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.

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.01%. Comparing base (16abe6a) to head (6586970).
Report is 31 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #360      +/-   ##
==========================================
+ Coverage   95.68%   97.01%   +1.33%     
==========================================
  Files          14       15       +1     
  Lines         950     1173     +223     
==========================================
+ Hits          909     1138     +229     
+ Misses         41       35       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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