Support valibot (lightweight version of zod)
lopezjurip opened this issue · comments
Consider Valibot over Zod: achieves lighter bundles & modularity, enhancing performance & flexibility.
https://bundlephobia.com/package/zod@3.22.4
It's 57KB gziped.
@lopezjurip Hi!
I agree adding valibot support to this plugin.
Could you send me PR for this? Thanks!
@Code-Hex @lopezjurip
I am a fan of graphql-codegen-typescript-validation-schema and valibot. I would like to submit a PR because I would like to use these two in a project I am working on! May I assign this issue to me?
@MH4GF Sure! I'm looking forward your PR!
@Code-Hex Please let me confirm about the definedNonNullAny
that is zod's temporary hack.
Surprisingly, valibot seems to compile the following code:
import * as v from 'valibot';
type A = {
foo: any;
};
function AParser(): v.ObjectSchema<A, undefined> {
return v.object({
foo: v.any()
});
}
const result = v.safeParse(AParser(), {
foo: 'bar',
});
console.log(result);
type InferA = v.InferOutput<ReturnType<typeof AParser>>;
// =>
// type InferA = {
// foo: any;
// }
So, is the schema to be generated correct with the intention of v.object({ foo: v.any() })
?
ref: colinhacks/zod#951
@MH4GF Thank you for your question.
In zod, I employed a hack to define a schema for the any type that excludes undefined and null. I hope to create something that aligns with this intention.
Does this answer your question?