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

Proprietary schemas using native zod methods and Metadata #1442

Merged
merged 67 commits into from
Jan 10, 2024

Conversation

RobinTail
Copy link
Owner

@RobinTail RobinTail commented Jan 4, 2024

I was dreaming about it.
Unfortunately zod does not provide any way to make a custom or branded or third-party schema that can be identified as one programmatically. Developer of zod also does not want to make any method to store metadata in schemas, instead, recommends to wrap schemas in some other structures, which is not suitable for the purposes of express-zod-api. There are many small inconvenient things in making custom schema classes, that I'd like to replace into native methods, and use withMeta wrapper for storing proprietary identifier, so the generators and walkers could still handle it.

Related issues:

https://github.com/colinhacks/zod/issues/1718
https://github.com/colinhacks/zod/issues/2413
https://github.com/colinhacks/zod/issues/273
https://github.com/colinhacks/zod/issues/71
https://github.com/colinhacks/zod/issues/37

PR I've been waiting for months to merged (programmatically distinguishable branding):

https://github.com/colinhacks/zod/pull/2860

@RobinTail RobinTail added enhancement New feature or request refactoring The better way to achieve the same result miracle Mysterious events are happening here labels Jan 4, 2024
@coveralls
Copy link

coveralls commented Jan 4, 2024

Coverage Status

coverage: 100.0%. remained the same
when pulling 50eb27d on experimental-prop-schemas
into 80fbd21 on master.

@RobinTail RobinTail changed the title Experiment: proprietary schemas using z.custom() and metadata Experiment: proprietary schemas using native methods and metadata Jan 5, 2024
@RobinTail RobinTail added the breaking Backward incompatible changes label Jan 5, 2024
@RobinTail RobinTail removed the breaking Backward incompatible changes label Jan 5, 2024
Copy link
Owner Author

@RobinTail RobinTail left a comment

Choose a reason for hiding this comment

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

Now I'm happy with it

@RobinTail RobinTail changed the title Experiment: proprietary schemas using native methods and metadata Proprietary schemas using native zod methods and Metadata Jan 8, 2024
@RobinTail
Copy link
Owner Author

I consider the experiment successful.

@RobinTail
Copy link
Owner Author

Time for a beta

@RobinTail RobinTail added the documentation Improvements or additions to documentation label Jan 10, 2024
@RobinTail
Copy link
Owner Author

✅ Regression test passed

Copy link
Owner Author

@RobinTail RobinTail left a comment

Choose a reason for hiding this comment

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

ready

@RobinTail RobinTail merged commit 60500c6 into master Jan 10, 2024
11 checks passed
@RobinTail RobinTail deleted the experimental-prop-schemas branch January 10, 2024 21:03
RobinTail added a commit that referenced this pull request Jan 29, 2024
Removing things deprecated in #1442 
Addressing the future v17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request miracle Mysterious events are happening here refactoring The better way to achieve the same result
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants