Skip to content

Instantly share code, notes, and snippets.

@mmikhan
Created March 12, 2025 18:27
Show Gist options
  • Save mmikhan/70601544091893e5422962935a09b6dd to your computer and use it in GitHub Desktop.
Save mmikhan/70601544091893e5422962935a09b6dd to your computer and use it in GitHub Desktop.
Zod mail configuration schema that takes a default empty value for an email field but also can be an empty string
export const mailConfigurationSchema = z.object({
apiKey: z.string().default(""),
fromEmail: z
.string()
.email()
.optional()
.or(z.literal(""))
.default(""),
toName: z.string().default(""),
toEmail: z
.string()
.email()
.optional()
.or(z.literal(""))
.default(""),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment