Skip to content

Instantly share code, notes, and snippets.

@ducva
Created January 8, 2024 13:51
Show Gist options
  • Select an option

  • Save ducva/66ad0167f24df27370a67137eb2666f4 to your computer and use it in GitHub Desktop.

Select an option

Save ducva/66ad0167f24df27370a67137eb2666f4 to your computer and use it in GitHub Desktop.
zod second
export const ChannelSchema = z.discriminatedUnion('type', [
z.object({
id: z.string(),
name: z.string(),
type: z.literal(ChannelType.LINE),
config: LineChannelConfigSchema
}),
z.object({
id: z.string(),
name: z.string(),
type: z.literal(ChannelType.MAIL),
config: MailChannelConfigSchema
})
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment