Skip to content

Add Standard Schema adapter #575

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add Standard Schema adapter #575

wants to merge 4 commits into from

Conversation

sillvva
Copy link
Contributor

@sillvva sillvva commented Mar 3, 2025

  • My IDE also sorted the imports in a few files

https://standardschema.dev/

Standard Schema is a common interface designed to be implemented by JavaScript and TypeScript schema libraries.

The goal is to make it easier for ecosystem tools to accept user-defined type validators, without needing to write custom logic or adapters for each supported library. And since Standard Schema is a specification, they can do so with no additional runtime dependencies. Integrate once, validate anywhere.

What schema libraries implement the spec?

These are the libraries that have already implemented the Standard Schema interface. (If you maintain a library that implements the spec, create a PR to add yourself!)

Implementer Version(s) Link
Zod 3.24.0+ PR
Valibot v1.0+ PR
ArkType v2.0+ PR
Effect Schema v3.13.0+ PR
Arri Schema v0.71.0+ PR
TypeMap v0.8.0+ PR
Formgator v0.1.0+ PR
decoders v2.6.0+ PR
ReScript Schema v9.2.0+ PR
Skunkteam Types v9.0.0+ PR

- My IDE also sorted the imports
Copy link

vercel bot commented Mar 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
superforms ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 1:01pm

@ciscoheat
Copy link
Owner

Great work on this, I couldn't add it to the latest release unfortunately, too much in the backlog!

I'm also curious if the defaults option is required, as it's not possible to know if there is full JSON Schema support for the adapter? (Check the Arktype adapter for how it differs to other adapters which doesn't require defaults)

- Updated `_standard` function to use `RequiredDefaultsOptions`
@sillvva
Copy link
Contributor Author

sillvva commented Mar 10, 2025

That's a good idea. Arktype is one of the compatible libraries, so if it requires defaults, then the standard schema should too.

It is also possible to tell either at runtime or in the types which vendor it is:

// type
T['~standard`]['vendor'] extends "arktype"

// runtime
schema['~standard'].vendor === "arktype"

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.

2 participants