Replies: 1 comment 7 replies
-
|
It would make the code easier to read with a ```typescript prefix on the code block. Is there a reason you are manually defining export const UserSchema = z
.object({
id: z.string(),
isAdmin: z.boolean().default(false),
adminSecret: z.string().max(20).optional(),
adminCode: z.string().length(4).optional(),
})
export type User = z.infer<typeof UserSchema>
const myUser: User = UserSchema.parse({ id: "foo" }) |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I thought that it would be helpful if we could review complicated schemas here. Let me start. Consider the schema below. How could I do better?
Things to think about:
z.object({ ... }).refine(adminSecretLogic).refine(adminCodeLogic).Beta Was this translation helpful? Give feedback.
All reactions