2
0

♻️ Replace schemas with merge and discriminated unions

Closes #374
This commit is contained in:
Baptiste Arnaud
2023-03-14 16:42:12 +01:00
parent ff09814ead
commit d154c4e2f2
52 changed files with 3217 additions and 4328 deletions

View File

@ -5,7 +5,7 @@ import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
import { defaultButtonLabel } from './constants'
import { InputBlockType } from './enums'
export const choiceInputOptionsSchema = optionBaseSchema.and(
export const choiceInputOptionsSchema = optionBaseSchema.merge(
z.object({
isMultipleChoice: z.boolean(),
buttonLabel: z.string(),
@ -18,14 +18,14 @@ export const defaultChoiceInputOptions: ChoiceInputOptions = {
isMultipleChoice: false,
}
export const buttonItemSchema = itemBaseSchema.and(
export const buttonItemSchema = itemBaseSchema.merge(
z.object({
type: z.literal(ItemType.BUTTON),
content: z.string().optional(),
})
)
export const choiceInputSchema = blockBaseSchema.and(
export const choiceInputSchema = blockBaseSchema.merge(
z.object({
type: z.enum([InputBlockType.CHOICE]),
items: z.array(buttonItemSchema),