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

Is it possible to remove/omit fields from a Schema? #96

Open
justin0mcateer opened this issue Sep 29, 2024 · 1 comment
Open

Is it possible to remove/omit fields from a Schema? #96

justin0mcateer opened this issue Sep 29, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@justin0mcateer
Copy link

Sometimes we have derived types where we use the Omit utility type. This is often where you have some canonical type and you need some version where certain fields are not provided, for example 'id' or 'updatedAt' where those two fields are automatically generated and not accepted in the input from the client. Particularly when there are multiple derived types, it is easier to start with the full/canonical type then remove/omit certain fields to created the derived types.

Could be my ignorance, but I cannot see a way to accomplish this with Rescript Schema currently.

For reference Zod offers both 'pick' and 'omit' functions to provide this capability.

@DZakh
Copy link
Owner

DZakh commented Sep 30, 2024

It's not currently possible, and I'm not sure it's even theoretically possible. It's probably implementable, but it needs some work.

There's https://github.com/DZakh/rescript-schema/blob/main/docs/rescript-usage.md#sflatten in ReScript API, which I can expose to TS API. This was designed to solve the case of reusing object schema shapes.

@DZakh DZakh added the enhancement New feature or request label Sep 30, 2024
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

2 participants