Ask questions[Request] Create schema from JSON

I’ve been using YUP which can’t do that and recently saw zod. Just wondering if this is on the table? A use case is a dynamically made schema by my users. Something like zod.importJSON(jsonOBJ)


Answer questions cybervaldez

It's certainly possible but it would break type inference. You can't pass a blob of untyped data into a hypothetical zod.importJSON(blob) function and get a statically typed validator out of it. Is that a problem?

Is this going to be on the roadmap? Another use-case is when using libraries like xstate or recoiljs which highly recommends primitive values for state persistence.

context: {
  validationSchema: z.string().optional(), 

// to something like:

context: {
  validationSchema: { type: 'string', 'optional' : true } 
Github User Rank List