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

Function assertDefaultValueAssignability

ark/schema/structure/optional.ts:173–186  ·  view source on GitHub ↗
(
	node: BaseRoot,
	value: unknown,
	key: PropertyKey | null,
	owner?: BaseNode
)

Source from the content-addressed store, hash-verified

171}
172
173export const assertDefaultValueAssignability = (
174 node: BaseRoot,
175 value: unknown,
176 key: PropertyKey | null,
177 owner?: BaseNode
178): unknown => {
179 // a function default is checked each time it's applied
180 if (isThunk(value)) return value
181
182 if (hasDomain(value, "object"))
183 throwParseError(writeNonPrimitiveNonFunctionDefaultValueMessage(key))
184
185 return checkDefault(node, value, key, owner)
186}
187
188// unlike its input, a thunk's result may be an object
189export const checkDefault = (

Callers 4

intersectPropsAndIndexFunction · 0.90
defaultFunction · 0.90
constructorMethod · 0.90
constructorMethod · 0.85

Calls 5

isThunkFunction · 0.90
hasDomainFunction · 0.90
throwParseErrorFunction · 0.90
checkDefaultFunction · 0.70

Tested by

no test coverage detected