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

feat: Implement standard schema interface #2258

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

logaretm
Copy link

@logaretm logaretm commented Dec 4, 2024

What

This is a PR that implements the standard schema interface for yup.

Motivation: Standard schema is an initiative that is aimed to get all Typed schema providers to support a unified interface that will enable various tools and 3rd party libraries to seamlessly integrate with "a schema provider" which reduces friction when migrating from one provider to the other, and allows mixing these providers if one is suited for a task more than the rest. Another benefit is it allows 3rd party authors to ditch the "resolver" pattern which in turn reduces their users' friction.

We discussed this briefly in #2255 with no clear green light given on this, so I understand if this is something you don't want the burden of maintaining. I already did the work locally to play with it, since I was planning to build a yup standard schema adapter anyways. So, I thought I might as well just PR it.

I made sure to add tests and type tests as well, happy to address any issues in this PR.

How

To avoid adding @standard-schema/spec as a dependency, I copied the types which is the recommended approach. I then make sure it is aligned with the spec by testing it against the spec which I added as a dev dependency.

I also had to implement a path splitter to make the paths compatible with the standard schema output.

Bundle size diff (~3%)

Label Size Before Size After
Bundle Size 72.6 KB 75.73 KB
Minified Size 39.07 KB 40.08 KB
Gzipped Size 11.44 KB 11.79 KB

closes #2255

@logaretm logaretm force-pushed the feat/implement-standard-schema branch from 70eb7f4 to 9ca5949 Compare January 5, 2025 12:59
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.

Support Standard-schema API?
1 participant