MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / validateOptionalPath

Method validateOptionalPath

src/mcp/tools.ts:1182–1196  ·  view source on GitHub ↗

* Validate an optional path-like string input. Returns the value if * valid (or undefined), or a ToolResult with the error.

(
    value: unknown,
    name: string
  )

Source from the content-addressed store, hash-verified

1180 * valid (or undefined), or a ToolResult with the error.
1181 */
1182 private validateOptionalPath(
1183 value: unknown,
1184 name: string
1185 ): string | undefined | ToolResult {
1186 if (value === undefined || value === null) return undefined;
1187 if (typeof value !== 'string') {
1188 return this.errorResult(`${name} must be a string`);
1189 }
1190 if (value.length > MAX_PATH_LENGTH) {
1191 return this.errorResult(
1192 `${name} exceeds maximum length of ${MAX_PATH_LENGTH} characters (got ${value.length})`
1193 );
1194 }
1195 return value;
1196 }
1197
1198 /**
1199 * Cached git worktree/index mismatch for a tool call's effective project.

Callers 1

executeMethod · 0.95

Calls 1

errorResultMethod · 0.95

Tested by

no test coverage detected