Skip to content

Conversation

@antoniocapelo
Copy link
Collaborator

@antoniocapelo antoniocapelo commented May 29, 2025

Refactor Form Validation and Schema Processing

Changes

  • Refactored schema processing and validation logic to be more maintainable, performant, and efficient
    • we now calculate a final schema and just run the field "building" on top of it.
    • this creates less "tree traversals" and less mutations happening
  • Fixed checkbox validation handling with dedicated error messages
  • Added support for hidden field type
  • Enhanced schema merging and property updates
  • Fixed a bug where react would go in an infinite update cycle (by returning new object instances, react would render the components multiple times. If these components had a useEffect that triggered a validation callback, an infinite loop might happen)

Key Improvements

  • Centralized schema calculation with new calculateFinalSchema function
  • Better handling of conditional rules and computed attributes
  • More robust field property updates with proper cleanup
  • Cleaner error message handling for checkboxes

Technical Details

  • Replaced mutateFields with more focused updateFieldProperties and calculateFinalSchema
  • Added isCheckbox helper and CHECKBOX_ERROR_MESSAGES constants
  • Improved type safety with better schema merging
  • Enhanced nested object handling in schema processing

@antoniocapelo antoniocapelo force-pushed the fix/fix-some-backward-compatible-code branch from 091b2a5 to ad59f0a Compare May 29, 2025 17:28
@antoniocapelo antoniocapelo marked this pull request as ready for review June 4, 2025 14:46
@antoniocapelo antoniocapelo requested review from dragidavid, lukad and sandrina-p and removed request for sandrina-p June 4, 2025 14:46
@antoniocapelo antoniocapelo self-assigned this Jun 4, 2025
@antoniocapelo antoniocapelo changed the title Fix/fix some backward compatible code chore: refactor field building approach + fix some issues with v0 backward compatibility Jun 4, 2025
Copy link
Collaborator

@dragidavid dragidavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment and a question but otherwise seems very clean. Did a quick test and it was working so that is cool 😄 impressive 💯

fix: provide empty fields for hidden fieldsets/group-arrays

chore: update test

feat: add 'value' fallback when const is not present for const validation

fix: delete conditional branches after processing them

chore: add comment
@antoniocapelo antoniocapelo force-pushed the fix/fix-some-backward-compatible-code branch from a957e27 to 1b6cc82 Compare June 4, 2025 21:33
@antoniocapelo
Copy link
Collaborator Author

@lukad @dragidavid For a final review, please check this commit, it's something I just added.

@antoniocapelo antoniocapelo requested review from dragidavid and lukad June 5, 2025 05:49
@antoniocapelo antoniocapelo merged commit 6f2e7d7 into main Jun 5, 2025
5 checks passed
@antoniocapelo antoniocapelo deleted the fix/fix-some-backward-compatible-code branch June 5, 2025 08:39
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.

5 participants