fix(utils): preserve boolean conditional branches in retrieveSchema#5101
Open
nkgotcode wants to merge 2 commits into
Open
fix(utils): preserve boolean conditional branches in retrieveSchema#5101nkgotcode wants to merge 2 commits into
nkgotcode wants to merge 2 commits into
Conversation
- convert matched boolean if/then/else branches to schema equivalents - add utils regression for then: false - add core submit regression for blocked form submission Fixes rjsf-team#4528
heath-freenome
left a comment
Member
There was a problem hiding this comment.
Can you please update the CHANGELOG. md with an appropriate comment in the @rjsf/utils section
| { [REF_KEY]: get(schema.additionalProperties, [REF_KEY]) } as S, | ||
| rootSchema, | ||
| formData as T, | ||
| get(formData, [key]) as T, |
Member
There was a problem hiding this comment.
Was this a bug fix that you found in addition to the changes above? If so, then I would suggest making sure there is a test to validate it.
|
|
||
| describe('getTestIds', () => { | ||
| describe('process.env.NODE_ENV === "test"', () => { | ||
| let oldNodeEnv: string | undefined; |
Member
There was a problem hiding this comment.
Was there a test issue here? Or did you do this for correctness?
| if (branch === undefined) { | ||
| return undefined; | ||
| } | ||
| return (typeof branch === 'boolean' ? (branch ? {} : { not: {} }) : branch) as S; |
Member
There was a problem hiding this comment.
Since the (branch ? {} : { not: {} }) : branch) as S; logic already exists in relaxOptionsForScoring() maybe it makes sense to refactor it into a small helper function used in both places?
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.
Summary
if/then/elsebranches to their schema equivalents duringretrieveSchema()resolutionthen: falseTest plan
cd packages/utils && npm run buildcd packages/utils && npx vitest run -c vitest.config.ts test/schema.test.ts --reporter=dot --coverage.enabled=falsecd packages/validator-ajv8 && npm run buildcd packages/core && npx vitest run -c vitest.config.ts test/validate.test.tsx --reporter=dotCloses #4528