Skip to content

fix: allow for computed values to be used inside conditionals #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

antoniocapelo
Copy link
Collaborator

@antoniocapelo antoniocapelo commented Jul 17, 2025

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 like if/then/else statements and allOf/anyOf compositions. This prevented dynamic schema modifications based on computed values within these conditional contexts.

Solution

  • Extended computed value processing: Updated cycleThroughPropertiesAndApplyValues to recursively process computed values within if, allOf, and anyOf schema structures
  • Re-applied schema rules: Added logic to re-apply schema rules after computed values are applied, ensuring all conditional logic is properly re-evaluated with the updated schema

Changes

  • 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 updates
  • src/types.ts: Updated comment style for consistency
  • test/validation/json-logic.test.ts: Added test case demonstrating computed values working within conditional statements

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.

2 participants