Respect serde renames for paths
Is there an obvious way to have garde respect serde rules (specifically, serde(rename_all = "camelCase")) for validation paths?
My public-facing input types are camel-cased to match the Javascript convention, but internally are snake-cased for Rust. When mapping errors back to form fields, I'd like to reflect the same convention.
Thanks.
There is not, unfortunately. I don't know what the convention for that is, but it feels wrong to read serde's attributes for this.
Implementing our own rename attributes would probably look like:
- Parsing the new attributes (
renameon field-level,rename_allon struct-level) - Following the code to thread those attributes through to this line and update the
key.to_string()based on whatever rename rule is used (either the struct-level case convert, or field-level rename to specific key, prioritizing the field-level over struct-level rename)
Thanks. Agreed, I think a garde-level rename makes sense 👍🏻 FWIW, I'm using Poem's #[oai(rename_all...) attribute for serialising input, which is effectively the same approach.
Implemented #157 using guidance from @jprochazk's reply. Did not implement the rename_all as it was a bit out of scope for me.