25 lines
958 B
TypeScript
25 lines
958 B
TypeScript
|
|
import { z } from 'zod';
|
||
|
|
|
||
|
|
export const formFieldSchema = z.object({
|
||
|
|
key: z.string().min(1).max(80),
|
||
|
|
label: z.string().min(1).max(200),
|
||
|
|
type: z.enum(['text', 'textarea', 'email', 'phone', 'number', 'select', 'checkbox']),
|
||
|
|
required: z.boolean().optional().default(false),
|
||
|
|
options: z.array(z.string()).optional(),
|
||
|
|
helpText: z.string().optional(),
|
||
|
|
});
|
||
|
|
|
||
|
|
export const createFormTemplateSchema = z.object({
|
||
|
|
name: z.string().min(1).max(200),
|
||
|
|
description: z.string().optional(),
|
||
|
|
fields: z.array(formFieldSchema).min(1, 'At least one field is required'),
|
||
|
|
branding: z.record(z.unknown()).optional(),
|
||
|
|
isActive: z.boolean().optional().default(true),
|
||
|
|
});
|
||
|
|
|
||
|
|
export const updateFormTemplateSchema = createFormTemplateSchema.partial();
|
||
|
|
|
||
|
|
export type FormField = z.infer<typeof formFieldSchema>;
|
||
|
|
export type CreateFormTemplateInput = z.infer<typeof createFormTemplateSchema>;
|
||
|
|
export type UpdateFormTemplateInput = z.infer<typeof updateFormTemplateSchema>;
|