Skip to content

Dev - #53

Merged
erayhanoglu merged 6 commits into
mainfrom
dev
Sep 10, 2026
Merged

Dev#53
erayhanoglu merged 6 commits into
mainfrom
dev

Conversation

@erayhanoglu

Copy link
Copy Markdown
Member

No description provided.

erayhanoglu and others added 6 commits September 9, 2026 08:06
…ctice

Adds a docs-baseline comment block to docs/api.md recording the git
commit/package version the docs were last verified against, and a
CLAUDE.md rule for keeping it current: diff src/ from that commit
before trusting/updating the docs, update only what actually changed,
then bump the baseline to the new HEAD.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Two related bugs in the same code path:

1. oneOf mocks context.fail while trying each candidate (so a candidate
   failing is normal control flow, not an accumulated error) but the
   mock discarded the failure reason entirely. When every candidate
   failed - including when one threw a genuinely unexpected exception
   (a bug, not a normal validation failure) - the only thing that
   surfaced was oneOf's own generic "Value didn't match one of required
   rules", with zero trace of what actually went wrong. The mock now
   remembers the last candidate's failure message and appends it as
   "(last error: <reason>)", plus a structured `lastError` field on the
   issue - without changing the "try the next candidate" control flow
   the existing tests rely on.

2. Related and more serious: when a candidate threw directly (bypassing
   context.fail, e.g. a plain function rather than one built with
   validator()), `passed` was never reset to false in the catch block.
   If that was the last candidate tried, oneOf would exit its loop with
   `passed` still true from loop-top initialization and silently return
   an unvalidated value instead of failing - a false positive, not just
   a lost message. Both catch blocks now correctly set `passed = false`.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… one

Following up on the previous fix: appending "(last error: ...)" to
oneOf's own generic message was still burying the actual, actionable
error behind boilerplate text. oneOf can only report one message
anyway, so when every candidate fails, it now reports that last
candidate's own message directly - the generic "Value didn't match one
of required rules" is only used when there's truly nothing to report
(e.g. an empty rules array).

Tests and docs updated to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@erayhanoglu
erayhanoglu merged commit b5e3b91 into main Sep 10, 2026
4 checks passed
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