You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My vague idea is that we could have a ValidateEntry trait that you implement for each entry type. The ValidateEntry trait has a few functions validate_create, validate_update, validate_delete which by default return ValidateCallbackResult::Valid (or don't have a default implementation if we want to force app devs to be explicit).
Then we do some refactoring of the Op transformation such that we can just run the validate function for that entry type with the provided data.
For LinkTypes, rust doesn't allow enum variants to impl traits so we might have to come up with some workaround - either a change to the hdk for how you define a LinkType, or something at the app level to associate a linktype variant to a trait implementation.
I know this is vague and definitely would need an exploratory spike to feel it out. But I think this could be ideal -- if it worked then scaffolding and app devs may never have to touch the validate callback, and can just implement this trait for their entry & link types.
c12i
changed the title
refactor: Improve the quality/ readability of generated validation rust code
spike: Improve the quality/ readability of generated validation rust code
Nov 5, 2024
Goals
Explore the possibility of using declarative macros to reuse a lot of repeated code
Firstly, identify instances of repeated code in the validation logic and identify code
that can be grouped into a single macro
The text was updated successfully, but these errors were encountered: