From 0122a9321298246033db029bab57d71d2e77f4c8 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 3 Oct 2026 11:28:17 -0400 Subject: [PATCH] Trim emails before validating them Zod ran the email format check before trim, so an address with a trailing space was rejected as invalid. iOS keyboards commonly add one after autocomplete. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8 --- packages/shared/src/schemas.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/shared/src/schemas.ts b/packages/shared/src/schemas.ts index 38fdf48..f149ed1 100644 --- a/packages/shared/src/schemas.ts +++ b/packages/shared/src/schemas.ts @@ -7,14 +7,17 @@ export const usernameSchema = z .toLowerCase() .regex(/^[a-z0-9_]{3,32}$/, 'Username must be 3-32 characters: letters, numbers, underscores'); +// Trim before validating: iOS keyboards often append a space after autocompleting an email. +const emailSchema = z.string().trim().toLowerCase().pipe(z.email()); + export const registerSchema = z.object({ username: usernameSchema, - email: z.email().trim().toLowerCase(), + email: emailSchema, password: z.string().min(8, 'Password must be at least 8 characters').max(200), }); export const loginSchema = z.object({ - email: z.email().trim().toLowerCase(), + email: emailSchema, password: z.string().min(1).max(200), });