MCPcopy Create free account
hub / github.com/arktypeio/arktype / isLabeledIssue

Function isLabeledIssue

ark/schema/shared/issues.ts:810–837  ·  view source on GitHub ↗
(
	issue: ReadableIssue,
	message: string,
	defaultMessage: string
)

Source from the content-addressed store, hash-verified

808}
809
810const 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` */
840export const issueLineOf = (issue: ReadableIssue): string => {

Callers 1

issueLineOfFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected