(name: string)
| 5 | * - Pattern: [a-z0-9_-]{1,64} |
| 6 | */ |
| 7 | export 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 | } |
no test coverage detected