Skip to content

docs(zod-validator, standard-validator): document default error response format - #2060

Open
arsalanghogari wants to merge 2 commits into
honojs:mainfrom
arsalanghogari:docs/validator-error-format
Open

docs(zod-validator, standard-validator): document default error response format#2060
arsalanghogari wants to merge 2 commits into
honojs:mainfrom
arsalanghogari:docs/validator-error-format

Conversation

@arsalanghogari

@arsalanghogari arsalanghogari commented Aug 1, 2026

Copy link
Copy Markdown

Part 1 of the plan proposed in #2049 (docs first, opt-in RFC 9457 formatter as a possible follow-up).

What this adds

For both @hono/zod-validator and @hono/standard-validator READMEs:

  • A Default error response section showing the exact JSON body returned on validation failure when no hook is provided (captured from the current published packages), with notes that:
    • zod-validator returns Zod's serialized safeParse result, where error.message is a JSON string of the issue array
    • standard-validator echoes the raw request input back in data, which may be undesirable for sensitive values
    • neither format is guaranteed stable, so clients parsing the body should use a hook
  • A hook example producing an RFC 9457 Problem Details response with application/problem+json, so the standard format is one copy-paste away

Both example hooks were run against the current packages to confirm they work as shown. Docs only, no behavior changes, so no changeset included.

@changeset-bot

changeset-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6ae4b1c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

…se format

Documents the exact JSON body each validator returns on validation
failure when no hook is provided, and adds a hook example producing
an RFC 9457 Problem Details response.

Refs honojs#2049
@arsalanghogari
arsalanghogari force-pushed the docs/validator-error-format branch from 2e07621 to 8f9cfa9 Compare August 1, 2026 09:21
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.14%. Comparing base (84984d4) to head (6ae4b1c).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2060   +/-   ##
=======================================
  Coverage   92.14%   92.14%           
=======================================
  Files         115      115           
  Lines        4113     4113           
  Branches     1072     1072           
=======================================
  Hits         3790     3790           
  Misses        287      287           
  Partials       36       36           
Flag Coverage Δ
oauth-providers 92.55% <ø> (ø)
standard-validator 96.10% <ø> (ø)
ua-blocker 90.00% <ø> (ø)
zod-validator 91.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant