feat: Implement username change functionality

This commit is contained in:
gpt-engineer-app[bot]
2025-09-28 17:53:37 +00:00
parent 3e1ea57c11
commit 6b329f6887
6 changed files with 282 additions and 22 deletions

17
src/lib/validation.ts Normal file
View File

@@ -0,0 +1,17 @@
import { z } from 'zod';
export const usernameSchema = z
.string()
.min(3, 'Username must be at least 3 characters')
.max(30, 'Username must be less than 30 characters')
.regex(/^[a-zA-Z0-9_-]+$/, 'Username can only contain letters, numbers, underscores, and hyphens')
.regex(/^[a-zA-Z0-9]/, 'Username must start with a letter or number')
.transform(val => val.toLowerCase());
export const profileEditSchema = z.object({
username: usernameSchema,
display_name: z.string().max(100, 'Display name must be less than 100 characters').optional(),
bio: z.string().max(500, 'Bio must be less than 500 characters').optional(),
});
export type ProfileEditForm = z.infer<typeof profileEditSchema>;