Repository navigation
fix(think-validator): keep a field's method from leaking into other requiredWith fields - #1792
Merged
lizheming merged 2 commits intoNov 4, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1792 +/- ##
=======================================
Coverage 72.75% 72.75%
=======================================
Files 241 241
Lines 19183 19184 +1
=======================================
+ Hits 13956 13957 +1
Misses 5227 5227
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
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.
Rules._requiredWithreassigns the sharedcurrentQueryinside themapover the listed fields. When one listed field declares its ownmethod, every field after it in the list is read from that method's params instead of the rule's own method, so the result depends on the order of the list.Example: with
target: {requiredWith: ['a', 'b'], method: 'get'},a: {method: 'post'}and the value ofbset in the GET params,targetis not required for['a', 'b'](b is read from POST), but it is required for['b', 'a'].This change uses a per-item
queryvariable, so each field only changes where it is read from. Behavior for fields without their ownmethodis unchanged.Test: added a case that checks both orders of the field list.
pnpm testinpackages/think-validator(Node v22.23.4):eslint: exit 0