2023-08-21 15:32:27 +02:00
|
|
|
import { CustomDomain as CustomDomainInDb } from '@typebot.io/prisma'
|
|
|
|
import { z } from 'zod'
|
|
|
|
|
|
|
|
const domainNameRegex = /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/
|
|
|
|
|
|
|
|
export const customDomainSchema = z.object({
|
2023-08-22 11:11:20 +02:00
|
|
|
name: z
|
|
|
|
.string()
|
|
|
|
.transform((name) => name.toLowerCase())
|
|
|
|
.refine((name) => domainNameRegex.test(name)),
|
2023-08-21 15:32:27 +02:00
|
|
|
workspaceId: z.string(),
|
|
|
|
createdAt: z.date(),
|
|
|
|
}) satisfies z.ZodType<CustomDomainInDb>
|