z.infer
schemas before default values are applied ?
#1137
Answered
by
lowlighter
lowlighter
asked this question in
Q&A
-
Hi! Not sure if I missed it in the doc, but is it possible to Consider the following: import { z } from "https://deno.land/x/zod@v3.14.4/mod.ts"
const schema = z.object({
foo:z.string().default("bar")
})
type input = {foo?: string} // How to obtain this type from schema ?
type output = z.infer<typeof schema> // { foo: "string" }
function validate(values: input): output {
return schema.parse(values)
} I'd like to generate Thanks a lot for your answers |
Beta Was this translation helpful? Give feedback.
Answered by
lowlighter
May 16, 2022
Replies: 1 comment
-
Ok so the solution was just to use |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lowlighter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok so the solution was just to use
schema["_input"]
👍