Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1398x 46x 46x 46x 1352x | import { isReason, type Reason } from '#/lib/reasons'
/** A field's first error as a reason code. Zod issues carry it as `message`. */
export function firstReason(errors: unknown[]): Reason | undefined {
for (const error of errors) {
const code =
typeof error === 'object' && error !== null && 'message' in error
? error.message
: error
Eif (isReason(code)) {
return code
}
}
return undefined
}
|