Files
thrilltrack-explorer/src-old/lib/contactValidation.ts

47 lines
1.4 KiB
TypeScript

import { z } from 'zod';
export const contactCategories = [
{ value: 'general', label: 'General Inquiry' },
{ value: 'moderation', label: 'Moderation Questions' },
{ value: 'technical', label: 'Technical Support' },
{ value: 'account', label: 'Account Issues' },
{ value: 'partnership', label: 'Partnership/Business' },
{ value: 'report', label: 'Report an Issue' },
{ value: 'other', label: 'Other' },
] as const;
export const contactFormSchema = z.object({
name: z
.string()
.trim()
.min(2, 'Name must be at least 2 characters')
.max(100, 'Name must be less than 100 characters'),
email: z
.string()
.trim()
.email('Invalid email address')
.max(255, 'Email must be less than 255 characters'),
subject: z
.string()
.trim()
.min(5, 'Subject must be at least 5 characters')
.max(200, 'Subject must be less than 200 characters'),
category: z.string()
.refine(
(val) => ['general', 'moderation', 'technical', 'account', 'partnership', 'report', 'other'].includes(val),
{ message: 'Please select a valid category' }
),
message: z
.string()
.trim()
.min(20, 'Message must be at least 20 characters')
.max(2000, 'Message must be less than 2000 characters'),
captchaToken: z.string().min(1, 'Please complete the CAPTCHA'),
});
export type ContactFormData = z.infer<typeof contactFormSchema>;
export interface ContactSubmission extends ContactFormData {
userId?: string;
}