metosin / reitit

A fast data-driven routing library for Clojure/Script
https://cljdoc.org/d/metosin/reitit/
Eclipse Public License 1.0
1.4k stars 252 forks source link

Improve reitit malli humanize data so you can map the errors back to the submitted data. #670

Open juniper-oly opened 3 months ago

juniper-oly commented 3 months ago

Currently when ring returns a response containing humanize it does not tell you the corresponding spec/key that failed, ideally you would want to be able to map back to the input data.

Example being a spec which is being validated in html form when submitted would get a response but there seems to ne know way to know which field in the form had the error so deciding which field should have an error marked against it is difficult.

This would be nice to be built in, or at least allow it to be overriden so custom functionality could be added, seem this would be nicer to be built in as reitit is all about routing http requests so not sure why you might not want this available, adding it in though would likely cause breaking changes.

This is an example response, I submitted 2 fields user and password but I can't find a way to map the error back to those fields, discussed with @ikitommi suggested this would be looked at so I am creating this issue as a reminder.

"humanized":["invalid type","invalid type"]