(
issue: ArkIssue & { message: string },
prefix: array<PropertyKey>,
config: ResolvedConfig
)
| 253 | |
| 254 | // keeps the text a standalone validator wrote; its actual describes its data |
| 255 | export const errorOfIssue = ( |
| 256 | issue: ArkIssue & { message: string }, |
| 257 | prefix: array<PropertyKey>, |
| 258 | config: ResolvedConfig |
| 259 | ): ArkError => { |
| 260 | const message = issue.message ?? messageOf(issue) |
| 261 | const meta: ArkEnv.meta = { expected: issue.expected ?? message, message } |
| 262 | const error = stampError( |
| 263 | { |
| 264 | code: issue.code, |
| 265 | path: [...prefix, ...issue.path], |
| 266 | data: issue.data, |
| 267 | meta, |
| 268 | // a union's issue carries no branch errors |
| 269 | ...(issue.code === "union" && { errors: [] }) |
| 270 | } as never, |
| 271 | config |
| 272 | ) |
| 273 | // its line is the validator's, which wrote it as arktype would have |
| 274 | if (!isCustomIssue(issue)) templated.add(error) |
| 275 | if (!prefix.length && issue._l !== undefined) noteLine(error, issue._l) |
| 276 | if (issue._n !== undefined) labeledIssue(error, issue._n) |
| 277 | return error |
| 278 | } |
| 279 | |
| 280 | const mergeErrors = ( |
| 281 | errors: ArkErrors, |
no test coverage detected