Skip to content
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

Ability to create unions on the schema #17

Open
Didas-git opened this issue Sep 5, 2023 · 0 comments
Open

Ability to create unions on the schema #17

Didas-git opened this issue Sep 5, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Didas-git
Copy link
Owner

Didas-git commented Sep 5, 2023

This is something that im still thinking how i will handle it.
The main idea is that it would work like typescript unions so you can save more than 1 type of data within the same document.
However this brings some new issues to the table, those being:

  • Handling union validation
    • How do you know which union you are validating
  • Handling parsing
    • Same as validation but for parsing back into a js object

So the other option we have is to add a depends property.
With this you could say that a property only exists if said boolean is true, habdling this at runtime would be extremely simple leaving only the type-level stuff to worry.
In the type level it would create a union for the depends to reflect this exact case, however thats a little complicated and needs some experimentation to achieve the desired result without having to remake all the types, all we want is to update the type that does initial parsing since if it returns a union all other types should handle it properly, if doing so causes issues then the only type that should be changed is the mapping type, which now that im writting this might make more sense... we will see how it goes since this is more of an idea that could improve the user experience than something that is actually needed.

@Didas-git Didas-git added the enhancement New feature or request label Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant