Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/utils/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
};

Expand Down Expand Up @@ -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;
};

Expand Down
Loading