MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / formatValidationPath

Function formatValidationPath

source code/utils/toolErrors.ts:49–59  ·  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

47 * e.g., ['todos', 0, 'activeForm'] => 'todos[0].activeForm'
48 */
49function formatValidationPath(path: PropertyKey[]): string {
50 if (path.length === 0) return ''
51
52 return path.reduce((acc, segment, index) => {
53 const segmentStr = String(segment)
54 if (typeof segment === 'number') {
55 return `${String(acc)}[${segmentStr}]`
56 }
57 return index === 0 ? segmentStr : `${String(acc)}.${segmentStr}`
58 }, '') as string
59}
60
61/**
62 * 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