-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Support all standard schema libraries #299
Conversation
@EskiMojo14 is attempting to deploy a commit to the t3-oss Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I wonder if we should rename the presets entrypoint to |
sure, that'd make sense - you could maybe export interfaces from /presets that /presets-zod has to satisfy, to make sure they're all matching it'd be a breaking change but we've already got one of those anyway |
happy to make that change in this or a follow up PR if you want :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work 🔥
examples/astro-valibot/package.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would be nice with another example since we already have astro - but i don't really mind
}; | ||
} | ||
|
||
export function parseWithDictionary<TDict extends StandardSchemaDictionary>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice if we'd accept object validators so we wouldn't need this, but it was hell getting good types with ZodObject compared to Record<...> when I initially made this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the alternative would be requiring the user to provide the object schema builder as an option, but that seems a little annoying from a user perspective (and I haven't tested to make sure it's possible)
createEnv({
...opts,
buildObjectSchema: z.object
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need the raw shape to properly check if an accessed variable is shared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it should be possible to add (although not sure if StandardSchema has a shape
type like Zod has. it was just a pain and i think a Record<string, Validator> has worked fine
Yea go ahead! Breaking changes are fine. Either follow up or in this one is fine by me |
Actually I'll merge this now. You can make the preset changes in a follow up. lmk if you're doing them or not so i know if i should push a release or wait |
I'll get them done in the next hour or so, so if you're happy to wait to release I'll give you a shout |
sounds good |
@juliusmarminge raised #310 |
Replaces Zod specific logic and types with Standard Schema, meaning all of these should work.
fixes #6
Breaking changes:
ZodError
inonValidationError
with an array ofIssue
s.The minimum version of Zod has been bumped to 3.24, which is the first version to support Standard Schema. I've also made Zod an optional peer dependency, as it's now only needed for presets.
Once this is released, this package can be added here :)