-
-
Notifications
You must be signed in to change notification settings - Fork 51
feat: add validationSchemaExportType
to config
#382
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
Conversation
validationSchemaExportType
to config
@elijaholmos wow!! Amazing your work! I checked your code but still fails on the build.
There may be something wrong with the generation of union type. export const UserKindSchema = {
return z.union([AdminSchema, GuestSchema])
}; I think we are expected: export const UserKindSchema = z.union([AdminSchema, GuestSchema]) |
good catch, @Code-Hex! I updated the union generation code to fix that. however, I am now running into a new problem... depending on the order of the code generation, I can end up with a "variable being used before its declaration" error:
I was able to fix this with the enum declarations by hoisting them to the top of the file since they do not reference other schemas in their declarations, but this is more tricky with unions which directly reference other generated variables. In the above examples, I cannot hoist |
@elijaholmos Thanks! |
Resolves #164
Adds a new config option,
validationSchemaExportType
, to specify the export type of the generated validation schema (eitherfunction
orconst
), Feature supports yup, zod, and myzod.