2
0
Files
bot/packages/models/src/features/blocks/inputs/email.ts

37 lines
955 B
TypeScript
Raw Normal View History

import { z } from 'zod'
import {
defaultButtonLabel,
2022-06-11 07:27:38 +02:00
InputBlockType,
optionBaseSchema,
2022-06-11 07:27:38 +02:00
blockBaseSchema,
} from '../shared'
import { textInputOptionsBaseSchema } from './text'
export const emailInputOptionsSchema = optionBaseSchema
.and(textInputOptionsBaseSchema)
.and(
z.object({
// TODO: make it required once database migration is done
retryMessageContent: z.string().optional(),
})
)
2022-06-11 07:27:38 +02:00
export const emailInputSchema = blockBaseSchema.and(
z.object({
2022-06-11 07:27:38 +02:00
type: z.enum([InputBlockType.EMAIL]),
options: emailInputOptionsSchema,
})
)
export const defaultEmailInputOptions: EmailInputOptions = {
labels: {
button: defaultButtonLabel,
placeholder: 'Type your email...',
},
retryMessageContent:
"This email doesn't seem to be valid. Can you type it again?",
}
2022-06-11 07:27:38 +02:00
export type EmailInputBlock = z.infer<typeof emailInputSchema>
export type EmailInputOptions = z.infer<typeof emailInputOptionsSchema>