Dev - #53
Merged
Merged
Dev#53
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.