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

Function applyCallErrors

ark/type/runtime.ts:1073–1089  ·  view source on GitHub ↗
(
	apply: CompactApply,
	data: unknown,
	args: ValidatorArgs,
	onFail: ArkErrors.Handler | null,
	Ctx: new (data: unknown, config: unknown) => ArkErrors | InternalTraversal
)

Source from the content-addressed store, hash-verified

1071 applyCallErrors(elementsFrom(allows, apply, i, data), data, args, onFail, Ctx)
1072
1073export const applyCallErrors = (
1074 apply: CompactApply,
1075 data: unknown,
1076 args: ValidatorArgs,
1077 onFail: ArkErrors.Handler | null,
1078 Ctx: new (data: unknown, config: unknown) => ArkErrors | InternalTraversal
1079): unknown => {
1080 const ctx = new Ctx(data, runtimeConfig)
1081 apply(data, ctx)
1082 const errors = ctx instanceof ArkErrors ? ctx : ctx._errors
1083 if (!errors?.count) return data
1084 if (args.length) {
1085 if (args[0]) return args[0].piped(errors as never)
1086 if (args[1] !== undefined) onFail = args[1] as never
1087 }
1088 return onFail ? onFail(errors) : errors
1089}
1090
1091// Errors of a class no build wrote to find its issues once read, as an
1092// unbundled runtime's or another build's: a class beside it that does, its

Callers 1

applyElementsFunction · 0.85

Calls 3

onFailFunction · 0.85
pipedMethod · 0.80
applyFunction · 0.50

Tested by

no test coverage detected