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

Function applyKey

ark/schema/shared/compile.ts:541–566  ·  view source on GitHub ↗
(key: string, value: string, node: BaseNode)

Source from the content-addressed store, hash-verified

539
540 // a cyclic value is applied inline
541 private applyKey(key: string, value: string, node: BaseNode): this {
542 const apply =
543 node.entersAlias && node.hasAlias ?
544 `(${this.resolution(node, node.id, value)})`
545 : this.inv(node, { arg: value })
546 const fails = () => this.line("ctx.path.pop()").return(false)
547 this.line(`ctx.path.push(${key})`)
548 // only transforming a value Apply finds valid finds its morphs' errors
549 if (!node.hasAlias) {
550 this.if(
551 `${this.ref(transformsValid)}(ctx) && ${this.allows(node, value)}`,
552 () =>
553 this.line(
554 `${this.ref(transformedInApply)}(ctx, ${this.inv(node, { arg: value, kind: "Transform" })})`
555 )
556 ).elseIf(`!${apply}`, fails)
557 } else {
558 this.if(
559 node.tfs ?
560 `!(${this.ref(transformIfAllowed)}(ctx, ${this.ref(node)}, ${value}) || ${apply})`
561 : `!${apply}`,
562 fails
563 )
564 }
565 return this.line("ctx.path.pop()")
566 }
567
568 initTf(transformedChildren: readonly BaseNode[]): this {
569 this.checksErrs = transformedChildren.some(

Callers

nothing calls this directly

Calls 7

resolutionMethod · 0.80
lineMethod · 0.80
elseIfMethod · 0.80
ifMethod · 0.80
allowsMethod · 0.80
invMethod · 0.45
refMethod · 0.45

Tested by

no test coverage detected