Idiomatic HTML form handling #2642
Unanswered
krazyuniks
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Could you elaborate on what custom error handling you want to do? Are you using |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Hi,
I'm using axum_extra::extract::form which uses serde_html_form under the hood. The deserialization fails if an html form is submitted with the wrong type, say age=twenty instead of 20. This causes the extractor to fail and we never get the original form data so we can show the user the errors. What is the pattern to handle this? Currently I am maintaining one extractor form where all fields are Option String, so the form can be extracted regardless of input, and then building a second validation struct with the real field types to maintain the original submitted data and build error messages. This works but is not elegant. Any advice on the approach welcome.
I've seen some custom extractors but I don't think they could pass individual error messages and original data for each field.
axum version
0.7.4
Beta Was this translation helpful? Give feedback.
All reactions