mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 08:51:16 -05:00
feat: Implement username change functionality
This commit is contained in:
17
src/lib/validation.ts
Normal file
17
src/lib/validation.ts
Normal 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>;
|
||||
Reference in New Issue
Block a user