From 1c6cdb8328aaca0fa8138ab7feed82d1c82b77d2 Mon Sep 17 00:00:00 2001 From: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:05:03 +0530 Subject: [PATCH] refactor: added validation for display_name (#1823) --- .../[workspaceSlug]/me/profile/index.tsx | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/apps/app/pages/[workspaceSlug]/me/profile/index.tsx b/apps/app/pages/[workspaceSlug]/me/profile/index.tsx index 2d9377b51c..71c9cd094b 100644 --- a/apps/app/pages/[workspaceSlug]/me/profile/index.tsx +++ b/apps/app/pages/[workspaceSlug]/me/profile/index.tsx @@ -205,9 +205,6 @@ const Profile: NextPage = () => {

Full Name

-

- This name will be reflected on all the projects you are working on. -

{

Display Name

- The email address that you are using. + This could be your first name, or a nickname — however you{"'"}d like people to + refer to you in Plane.

@@ -246,13 +244,19 @@ const Profile: NextPage = () => { placeholder="Enter your display name" validations={{ required: "Display name is required.", - minLength: { - value: 3, - message: "Display name must be at least 3 characters long.", - }, - maxLength: { - value: 20, - message: "Display name should not exceed 20 characters", + validate: (value) => { + if (value.trim().length < 1) return "Display name can't be empty."; + + if (value.split(" ").length > 1) + return "Display name can't have two consecutive spaces."; + + if (value.replace(/\s/g, "").length < 1) + return "Display name must be at least 1 characters long."; + + if (value.replace(/\s/g, "").length > 20) + return "Display name must be less than 20 characters long."; + + return true; }, }} />