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

Function sharedMessageOf

ark/schema/shared/errors.ts:1278–1297  ·  view source on GitHub ↗
(
	errors: readonly ArkError[],
	locale: Locale.Resolved
)

Source from the content-addressed store, hash-verified

1276// that begins as the locale's own would is listed with what the others
1277// expect, as a validator's is, whose issue holds only its message
1278const sharedMessageOf = (
1279 errors: readonly ArkError[],
1280 locale: Locale.Resolved
1281): string | undefined => {
1282 let shared: string | undefined
1283 for (const e of errors) {
1284 const text =
1285 (
1286 configuredMessageOf(e) !== undefined ||
1287 suppliedText(e, "message") !== undefined
1288 ) ?
1289 beginsAsOwn(e, locale) ? undefined
1290 : e.message
1291 : e.code === "union" ? sharedMessageOf(e.errors, locale)
1292 : undefined
1293 if (text === undefined || (shared !== undefined && text !== shared)) return
1294 shared = text
1295 }
1296 return shared
1297}
1298
1299export const writeText = (
1300 error: ArkError,

Callers 1

writeAtPathsFunction · 0.70

Calls 3

configuredMessageOfFunction · 0.85
suppliedTextFunction · 0.85
beginsAsOwnFunction · 0.85

Tested by

no test coverage detected