| 808 | } |
| 809 | |
| 810 | const isLabeledIssue = ( |
| 811 | issue: ReadableIssue, |
| 812 | message: string, |
| 813 | defaultMessage: string |
| 814 | ): boolean => { |
| 815 | if ((issue as ArkIssue)._n !== undefined) return true |
| 816 | // a JSON-round-tripped ArkError loses its non-enumerable _n note, keeping |
| 817 | // either meta/valueMeta.label (JSON.stringify(error)) or `<label> <default>` |
| 818 | // (ArkErrors.toJSON()) |
| 819 | const meta = |
| 820 | issue.code === "required" ? |
| 821 | (issue as { valueMeta?: { label?: unknown; message?: unknown } }) |
| 822 | .valueMeta |
| 823 | : (issue as { meta?: { label?: unknown; message?: unknown } }).meta |
| 824 | if ( |
| 825 | typeof meta?.label === "string" && |
| 826 | meta.message === undefined && |
| 827 | message.startsWith(meta.label + " ") |
| 828 | ) |
| 829 | return true |
| 830 | return ( |
| 831 | !("data" in issue) && |
| 832 | (issue.expected !== undefined || issue.code === "required") && |
| 833 | message.length > defaultMessage.length + 1 && |
| 834 | (message.endsWith(" " + defaultMessage) || |
| 835 | message.includes(" " + defaultMessage + " ")) |
| 836 | ) |
| 837 | } |
| 838 | |
| 839 | /** @internal formats a standalone issue as its line in `errors.summary` */ |
| 840 | export const issueLineOf = (issue: ReadableIssue): string => { |