Skip to content

feat(validation): add machine-readable Code and Params to ErrorDetail#1000

Open
Micaso wants to merge 1 commit intodanielgtaylor:mainfrom
Micaso:feat/structured-error-codes
Open

feat(validation): add machine-readable Code and Params to ErrorDetail#1000
Micaso wants to merge 1 commit intodanielgtaylor:mainfrom
Micaso:feat/structured-error-codes

Conversation

@Micaso
Copy link
Copy Markdown
Contributor

@Micaso Micaso commented Mar 20, 2026

Validation errors previously exposed only a human-readable Message string,
making it impossible to programmatically handle specific error types without
fragile string parsing.

Add Code (snake_case identifier) and Params (constraint parameters) fields
to ErrorDetail, along with matching Code* constants in the validation package.
All internal call sites are migrated to the new ValidateResult.AddCode()
method which threads the code and params through.

Both fields are omitempty and fully backwards-compatible. Consumers can now
switch on detail.Code and read structured params (e.g. allowed enum values,
numeric bounds, required property names) without touching Message.

Closes #999

  Validation errors previously exposed only a human-readable Message string,
  making it impossible to programmatically handle specific error types without
  fragile string parsing.

  Add Code (snake_case identifier) and Params (constraint parameters) fields
  to ErrorDetail, along with matching Code* constants in the validation package.
  All internal call sites are migrated to the new ValidateResult.AddCode()
  method which threads the code and params through.

  Both fields are omitempty and fully backwards-compatible. Consumers can now
  switch on detail.Code and read structured params (e.g. allowed enum values,
  numeric bounds, required property names) without touching Message.

  Closes danielgtaylor#999
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.08%. Comparing base (a38b536) to head (73f1c46).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1000      +/-   ##
==========================================
+ Coverage   93.07%   93.08%   +0.01%     
==========================================
  Files          23       23              
  Lines        4780     4789       +9     
==========================================
+ Hits         4449     4458       +9     
  Misses        271      271              
  Partials       60       60              

☔ View full report in Codecov by Sentry.
📢 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.

feat: add machine-readable Code and Params fields to ErrorDetail

1 participant