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

Function check

ark/schema/shared/compile.ts:681–696  ·  view source on GitHub ↗
(node: BaseNode, opts?: CheckOptions)

Source from the content-addressed store, hash-verified

679 }
680
681 check(node: BaseNode, opts?: CheckOptions): this {
682 const arg = opts?.arg ?? this.data
683 const condition =
684 opts?.kind || (this.trav === "Apply" && node.is("union")) ?
685 undefined
686 : node.jsCond?.(this, arg)
687 const fail = () => (opts?.breaks ? this.line("break") : this.return(false))
688 if (condition === undefined)
689 return this.if(`!${this.inv(node, opts)}`, fail)
690 return this.if(
691 this.trav === "Allows" ?
692 `!(${condition})`
693 : `!(${condition}) && ${this.error(node, undefined, arg)}`,
694 fail
695 )
696 }
697
698 checkLeaf(node: BaseNode): this {
699 const condition = node.jsCond!(this, this.data)!

Callers 2

entryAtUndeclaredKeyFunction · 0.50
checkArgsMethod · 0.50

Calls 5

isMethod · 0.80
ifMethod · 0.80
jsCondMethod · 0.45
invMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected