From 6deb3c60a04dde475390765a0b4773eb7bec2291 Mon Sep 17 00:00:00 2001 From: okxint Date: Thu, 18 Jun 2026 16:09:45 +0530 Subject: [PATCH] fix: Require at least one alphanumeric char in workspace name `COMPANY_NAME_REGEX` blocks disallowed chars but accepts symbol-only strings like `-_________-` since `-` and `_` are in the allowed set. Add `HAS_ALPHANUMERIC_REGEX` and check it in `validateWorkspaceName` and `validateCompanyName` so inputs with no letter or digit are rejected. Fixes makeplane/plane#9255 Signed-off-by: okxint --- packages/utils/src/validation.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/utils/src/validation.ts b/packages/utils/src/validation.ts index 41c52aaa133..2b61a4a54d5 100644 --- a/packages/utils/src/validation.ts +++ b/packages/utils/src/validation.ts @@ -41,6 +41,12 @@ export const DISPLAY_NAME_REGEX = /^[\p{L}\p{N}_.-]+$/u; */ export const COMPANY_NAME_REGEX = /^[\p{L}\p{N}\s_-]+$/u; +/** + * Requires at least one Unicode letter or digit in a string. + * Used to reject symbol-only inputs like "-_________-" in workspace/company names. + */ +export const HAS_ALPHANUMERIC_REGEX = /[\p{L}\p{N}]/u; + /** * URL Slug Pattern (for workspace slugs, URL-safe identifiers) * Allows: Unicode letters (\p{L}), numbers (\p{N}), underscores, hyphens @@ -140,6 +146,10 @@ export const validateCompanyName = (companyName: string, required: boolean = fal return "Company name can only contain letters, numbers, spaces, hyphens, and underscores"; } + if (!HAS_ALPHANUMERIC_REGEX.test(companyName)) { + return "Company name must contain at least one letter or number"; + } + return true; }; @@ -170,6 +180,10 @@ export const validateWorkspaceName = (workspaceName: string, required: boolean = return "Workspace name can only contain letters, numbers, spaces, hyphens, and underscores"; } + if (!HAS_ALPHANUMERIC_REGEX.test(workspaceName)) { + return "Workspace name must contain at least one letter or number"; + } + return true; };