Skip to content

Type for a Zod Type? #3318

Answered by JacobWeisenburger
maxpaleo asked this question in Q&A
Discussion options

You must be logged in to vote

Is this what you are looking for?

interface AppInputInterface {
    label: string
    controlType: "text" | "select"
    type: z.ZodTypeAny
    type: z.Schema // also works
}

interface AppFormInterface {
    name: string
    schema: {
        [ key: string ]: AppInputInterface
    }
}

const createOrgFormSchema: AppFormInterface = {
    name: "create_org",
    schema: {
        organization_name: {
            label: "Organization name",
            type: z.string(), // works
            controlType: "text",
        },
        country: {
            label: "Country",
            controlType: "select",
            type: z.string(), // works
        },
    },
}

If you found my answer satis…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JacobWeisenburger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants