1f1128ff4a
- Extract validateWorkspaceSegment to commands/init/validate.ts - Unify splitProviderModelRef in config/, used by both resolve-model and registry-normalize - Warn on missing models.default during parse (tag Z2KP9NWQ)
16 lines
557 B
TypeScript
16 lines
557 B
TypeScript
import { err, ok, type Result } from "@uncaged/workflow";
|
|
|
|
/** Validates a single path segment for workspace / template names (no separators, not `.` / `..`). */
|
|
export function validateWorkspaceSegment(name: string): Result<void, string> {
|
|
if (name.length === 0) {
|
|
return err("workspace name must not be empty");
|
|
}
|
|
if (name === "." || name === "..") {
|
|
return err("invalid workspace name");
|
|
}
|
|
if (name.includes("/") || name.includes("\\")) {
|
|
return err("workspace name must not contain path separators");
|
|
}
|
|
return ok(undefined);
|
|
}
|