aboutsummaryrefslogtreecommitdiffstats
path: root/website/src/lib/schemas/profile.ts
blob: 72728006783d62a53789f621789168e8ccbce907 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { z } from 'zod';

export const profileSchema = z.object({
  username: z
    .string()
    .min(3, { message: 'Username must be at least 3 characters' })
    .max(20, { message: 'Username is too long' })
    .regex(/^[a-zA-Z0-9_]+$/, { message: 'Only letters, numbers, and underscores allowed' }),
  bio: z.string().max(160, { message: 'Bio must be under 160 characters' }).optional().default(''),
});

// Automatically generate a TS type from the Zod schema
export type ProfileSchema = z.infer<typeof profileSchema>;