From fde6de3fcf825c00260367093edf692279b41ce5 Mon Sep 17 00:00:00 2001 From: gakshita Date: Thu, 28 Aug 2025 16:04:50 +0530 Subject: [PATCH] fix: handled fe to not allow special characters in first_name and last_name --- .../components/onboarding/steps/profile/root.tsx | 5 +++++ apps/web/core/components/profile/form.tsx | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/apps/web/core/components/onboarding/steps/profile/root.tsx b/apps/web/core/components/onboarding/steps/profile/root.tsx index 90fc135d72..bd8a4c86ee 100644 --- a/apps/web/core/components/onboarding/steps/profile/root.tsx +++ b/apps/web/core/components/onboarding/steps/profile/root.tsx @@ -213,6 +213,11 @@ export const ProfileSetupStep: FC = observer(({ handleStepChange }) => { value: 24, message: "Name must be within 24 characters.", }, + validate: (value) => { + if (!/^[a-zA-Z0-9_-]+$/.test(value)) + return "First name can only contain letters, numbers, hyphens, and underscores."; + return true; + }, }} render={({ field: { value, onChange, ref } }) => ( { name="first_name" rules={{ required: "Please enter first name", + validate: (value) => { + if (!/^[a-zA-Z0-9_-]+$/.test(value)) + return "First name can only contain letters, numbers, hyphens, and underscores."; + return true; + }, }} render={({ field: { value, onChange, ref } }) => ( { { + if (!/^[a-zA-Z0-9_-]+$/.test(value)) + return "Last name can only contain letters, numbers, hyphens, and underscores."; + return true; + }, + }} render={({ field: { value, onChange, ref } }) => ( { /> )} /> + {errors?.last_name && {errors?.last_name?.message}}