fix: allow for computed values to be used inside conditionals #215
+265
−6
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.
Fix: Allow computed values to work within conditional schema structures
Problem
Computed values from JSON Logic (
x-jsf-logic-computedAttrs
) were not being properly applied when used inside conditional schema structures likeif
/then
/else
statements andallOf
/anyOf
compositions. This prevented dynamic schema modifications based on computed values within these conditional contexts.Solution
cycleThroughPropertiesAndApplyValues
to recursively process computed values withinif
,allOf
, andanyOf
schema structuresChanges
src/validation/json-logic.ts
: Extended the computed values processing to handle conditional schemas (if
,allOf
,anyOf
)src/mutations.ts
: Added re-application of schema rules after computed values are applied to ensure proper field updatessrc/types.ts
: Updated comment style for consistencytest/validation/json-logic.test.ts
: Added test case demonstrating computed values working within conditional statements