Is that possible to convert a type to validator?
Hi, to better maintain types in project, I wonder if there is a way to convert types to validators?
5 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Would it work for your use case to do the reverse, turning validators into types? Here's an example how to do that:
There may be a way to go the direction you asked. I just haven't played with it yet (or searched for a solution) to find out how.
There's not unfortunately, types in TypeScript don't exist at runtime. There are a variety of ways to try to do this with codegen/bundler extensions but nothing supported now.
thanks for your answers, I will take a look at other options!
actually, I looking for a solution to manage tyes and validators, and I found the following article, and it helps me a lot: https://stack.convex.dev/types-cookbook
Types and Validators in TypeScript: A Convex Cookbook
It can be tough to wrangle types to behave how you want them to. Thankfully, Convex was designed to make the experience with types perfect. Learn why ...