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

Runtime config / schema validation #214

Open
schickling opened this issue May 9, 2022 · 3 comments
Open

Runtime config / schema validation #214

schickling opened this issue May 9, 2022 · 3 comments

Comments

@schickling
Copy link
Collaborator

schickling commented May 9, 2022

Some users (typically users who don't yet use TypeScript) are running into problems due to misconfigurations of their Contentlayer config (especially in regards to the content schema). Additionally to the safety provided by TypeScript, we should also implement a runtime validation step to avoid undefined runtime errors.

Technical notes

Ideally we should figure out a way how to derive Zod-like validation logic based on the existing TypeScript definitions. We could also investigate to use TS+ for this.

Related issues

@ivan-kleshnin
Copy link

ivan-kleshnin commented Jun 30, 2022

You're likely talking about a different layer here, just FYI. As a contentlayer user I would certainly prefer well-known and tested zod schemas over custom type definitions within defineDocumentType: https://www.contentlayer.dev/docs/reference/source-files/field-types
-1 DSL to learn is a big deal.

@airtonix
Copy link

+1 if you could generate zod schemas then we can just infer types from that and we'd also be able to insert the schemas in the .input and .output of trpc routers:

@lucgagan
Copy link

lucgagan commented Jun 3, 2023

+1 for zod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants