feat(standard-validator): Add flattenErrors utility to @hono/standard-validator - #2050
feat(standard-validator): Add flattenErrors utility to @hono/standard-validator#2050KTrain5169 wants to merge 12 commits into
Conversation
Co-authored-by: stebeus <189894010+stebeus@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 97911fa The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
actually on second thought would it make more sense to name the function |
Yes, because it returns a flat object of an array of issues. But before doing that, the Valibot and Arktype tests need to be fixe, as these validators don't put object-level issues to |
It's verbose to do a one-to-one translation of a Zod/Valibot schema to ArkType, on which hints that ArkType is used differently from other validators.
Fix the Valibot and ArkType tests for `sortErrors`
|
just changed the function to I'll be sure to add this to the README later |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2050 +/- ##
=======================================
Coverage 92.14% 92.15%
=======================================
Files 115 115
Lines 4113 4128 +15
Branches 1072 1076 +4
=======================================
+ Hits 3790 3804 +14
- Misses 287 288 +1
Partials 36 36
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
yusukebe
left a comment
There was a problem hiding this comment.
Can you add how to use this flattenErrors to the README?
|
Hey @muningis! If you have time, can you review this? |
Yes, we can. @KTrain5169 I'll document this for you. |
thank you, was going to do it earlier but got swamped with other things to do :/ |
The author should do the following, if applicable
pnpm changesetat the top of this repo and push the changesetDescription
See #1987
This PR adds a new
flattenErrorsutility that sorts errors by form and field errors.For field errors, they are also keyed by error path.
Should be directly usable by passing in the
result.dataarray from a use of the middleware.thanks to @stebeus for testing initial implementation and offering an improved version of the utility