* Formats a Zod validation path into a readable string * e.g., ['todos', 0, 'activeForm'] => 'todos[0].activeForm'
(path: PropertyKey[])
| 45 | * e.g., ['todos', 0, 'activeForm'] => 'todos[0].activeForm' |
| 46 | */ |
| 47 | function 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 |
no outgoing calls
no test coverage detected