MCPcopy Index your code
hub / github.com/codeaashu/claude-code / formatValidationPath

Function formatValidationPath

src/utils/toolErrors.ts:47–57  ·  view source on GitHub ↗

* Formats a Zod validation path into a readable string * e.g., ['todos', 0, 'activeForm'] => 'todos[0].activeForm'

(path: PropertyKey[])

Source from the content-addressed store, hash-verified

45 * e.g., ['todos', 0, 'activeForm'] => 'todos[0].activeForm'
46 */
47function formatValidationPath(path: PropertyKey[]): string {
48 if (path.length === 0) return ''
49
50 return path.reduce((acc, segment, index) => {
51 const segmentStr = String(segment)
52 if (typeof segment === 'number') {
53 return `${String(acc)}[${segmentStr}]`
54 }
55 return index === 0 ? segmentStr : `${String(acc)}.${segmentStr}`
56 }, '') as string
57}
58
59/**
60 * Converts Zod validation errors into a human-readable and LLM friendly error message

Callers 1

formatZodValidationErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected