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

Function checkDefault

ark/type/runtime.ts:1406–1422  ·  view source on GitHub ↗
(
	validator: Validator,
	value: unknown,
	key: PropertyKey | null,
	defaultKey: DefaultKey
)

Source from the content-addressed store, hash-verified

1404
1405// checked once per key, thrown in en as a ParseError
1406export const checkDefault = (
1407 validator: Validator,
1408 value: unknown,
1409 key: PropertyKey | null,
1410 defaultKey: DefaultKey
1411): void => {
1412 const checked = checkedDefaultOf(defaultKey)
1413 if (checked.value) return
1414 const out = validator.traverse(value)
1415 if (out instanceof ArkErrors) {
1416 if (key === null) throwParseError(`Default ${out.summary}`)
1417 const atPath = new ArkErrors()
1418 mergeIssues(atPath, out, [key])
1419 throwParseError(`Default for ${atPath.summary}`)
1420 }
1421 checked.value = true
1422}
1423
1424export const checkInput = (
1425 value: unknown,

Callers

nothing calls this directly

Calls 4

throwParseErrorFunction · 0.90
traverseMethod · 0.80
checkedDefaultOfFunction · 0.70
mergeIssuesFunction · 0.50

Tested by

no test coverage detected