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

25 lines
787 B
TypeScript

import { z } from 'zod'
import { variableStringSchema } from '../../../utils'
import { optionBaseSchema, blockBaseSchema } from '../../shared'
import { InputBlockType } from '../constants'
import { textInputOptionsBaseSchema } from '../text'
export const numberInputOptionsSchema = optionBaseSchema
.merge(textInputOptionsBaseSchema)
.merge(
z.object({
min: z.number().or(variableStringSchema).optional(),
max: z.number().or(variableStringSchema).optional(),
step: z.number().or(variableStringSchema).optional(),
})
)
export const numberInputSchema = blockBaseSchema.merge(
z.object({
type: z.enum([InputBlockType.NUMBER]),
options: numberInputOptionsSchema.optional(),
})
)
export type NumberInputBlock = z.infer<typeof numberInputSchema>