Skip to content

feat: discriminatedUnion and reworked oneOf errors - #58

Merged
joanllenas merged 12 commits into
masterfrom
improve-errors
Jun 11, 2026
Merged

feat: discriminatedUnion and reworked oneOf errors#58
joanllenas merged 12 commits into
masterfrom
improve-errors

Conversation

@joanllenas

Copy link
Copy Markdown
Owner

Summary

  • Add discriminatedUnion decoder for tagged unions - validates only the matching variant and reports a precise error on unknown tags, avoiding the noise of oneOf trying every branch.
  • Rework oneOf failure output: replace the old "deepest path wins" heuristic with a no alternative matched (tried N) summary followed by every branch's failure; same-path issues collapse into X or Y messages.
  • Add formatIssuePath helper and use it in parse()/decodePromise() so array indices render with bracket notation (items[0] instead of items.0).
  • Fix enum error format to use JSON.stringify consistently with other primitive decoders.

@joanllenas
joanllenas merged commit 8ac88fc into master Jun 11, 2026
2 checks passed
@joanllenas
joanllenas deleted the improve-errors branch June 11, 2026 23:41
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.05%. Comparing base (3223366) to head (0201324).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #58      +/-   ##
==========================================
+ Coverage   98.65%   99.05%   +0.40%     
==========================================
  Files          25       26       +1     
  Lines         297      317      +20     
  Branches       88       93       +5     
==========================================
+ Hits          293      314      +21     
+ Misses          4        3       -1     

☔ 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.

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