(path: StandardSchemaV1.Issue["path"])
| 231 | } |
| 232 | |
| 233 | function formatIssuePath(path: StandardSchemaV1.Issue["path"]): string { |
| 234 | if (!path || path.length === 0) { |
| 235 | return "<root>"; |
| 236 | } |
| 237 | |
| 238 | const parts: string[] = []; |
| 239 | |
| 240 | for (const segment of path) { |
| 241 | const key = |
| 242 | typeof segment === "object" && segment !== null && "key" in segment |
| 243 | ? (segment as { key: PropertyKey }).key |
| 244 | : segment; |
| 245 | |
| 246 | if (typeof key === "number") { |
| 247 | parts.push(`[${key}]`); |
| 248 | continue; |
| 249 | } |
| 250 | |
| 251 | if (typeof key === "string") { |
| 252 | const isIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key); |
| 253 | if (parts.length === 0) { |
| 254 | parts.push(isIdentifier ? key : `[${JSON.stringify(key)}]`); |
| 255 | } else { |
| 256 | parts.push(isIdentifier ? `.${key}` : `[${JSON.stringify(key)}]`); |
| 257 | } |
| 258 | continue; |
| 259 | } |
| 260 | |
| 261 | const rendered = typeof key === "symbol" ? key.toString() : String(key); |
| 262 | parts.push(parts.length === 0 ? `[${rendered}]` : `[${rendered}]`); |
| 263 | } |
| 264 | |
| 265 | return parts.join(""); |
| 266 | } |
| 267 | |
| 268 | function getValidationErrorInfo( |
| 269 | cause: unknown |
no test coverage detected