2
0
Files
bot/packages/schemas/features/blocks/inputs/text/schema.ts
2023-12-22 09:13:53 +01:00

35 lines
798 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(),
})
)
.openapi({
title: 'Text',
ref: 'textInput',
})
export type TextInputBlock = z.infer<typeof textInputSchema>