Skip to content

Commit

Permalink
fix: added validation for username (only alphanumeric and dashes allo…
Browse files Browse the repository at this point in the history
…wed)
  • Loading branch information
Maczi01 committed Feb 17, 2024
1 parent 3f0e1bf commit 91ee7af
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion schema/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import z from "zod";
export const saveSettingsSchema = z.object({
name: z.string().min(1).max(50),
bio: z.string().max(200).optional(),
username: z.string().min(3).max(40, "Max username length is 40 characters."),
username: z
.string()
.min(3)
.max(40, "Max username length is 40 characters.")
.regex(
/^[a-zA-Z0-9-]+$/,
"Username can only contain alphanumerics and dashes.",
),
location: z
.string()
.max(100, "Max location length is 100 characters.")
Expand Down

0 comments on commit 91ee7af

Please sign in to comment.