2
0
Files
bot/packages/schemas/features/blocks/inputs/text/schema.ts
Baptiste Arnaud 35300eaf34 ♻️ Introduce typebot v6 with events (#1013)
Closes #885
2023-11-08 15:34:16 +01:00

30 lines
714 B
TypeScript

import { z } from 'zod'
import { optionBaseSchema, blockBaseSchema } from '../../shared'
import { InputBlockType } from '../constants'
export const textInputOptionsBaseSchema = z.object({
labels: z
.object({
placeholder: z.string().optional(),
button: z.string().optional(),
})
.optional(),
})
export const textInputOptionsSchema = textInputOptionsBaseSchema
.merge(optionBaseSchema)
.merge(
z.object({
isLong: z.boolean().optional(),
})
)
export const textInputSchema = blockBaseSchema.merge(
z.object({
type: z.enum([InputBlockType.TEXT]),
options: textInputOptionsSchema.optional(),
})
)
export type TextInputBlock = z.infer<typeof textInputSchema>