MCPcopy
hub / github.com/coder/mux / validateWorkspaceName

Function validateWorkspaceName

src/common/utils/validation/workspaceValidation.ts:7–28  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

5 * - Pattern: [a-z0-9_-]{1,64}
6 */
7export function validateWorkspaceName(name: string): { valid: boolean; error?: string } {
8 if (!name || name.length === 0) {
9 return { valid: false, error: "Workspace name cannot be empty" };
10 }
11
12 if (name.length > 64) {
13 return { valid: false, error: "Workspace name cannot exceed 64 characters" };
14 }
15
16 const validPattern = /^[a-z0-9_-]+$/;
17 if (!validPattern.test(name)) {
18 return {
19 valid: false,
20 // Workspace names become folder names, git branches, and session directories,
21 // so they need to be filesystem-safe across platforms.
22 error:
23 "Workspace names can only contain lowercase letters, numbers, hyphens, and underscores",
24 };
25 }
26
27 return { valid: true };
28}

Callers 11

useWorkspaceNameFunction · 0.90
createMethod · 0.90
createMultiProjectMethod · 0.90
renameMethod · 0.90
forkMethod · 0.90
createManyMethod · 0.90
createMethod · 0.90
RenameWorkspaceModalFunction · 0.90
handleSubmitFunction · 0.90

Calls 1

testMethod · 0.80

Tested by

no test coverage detected