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

Function writeRequired

ark/type/standalone/combinators.ts:799–819  ·  view source on GitHub ↗
(prop: Prop.Node, checker: string)

Source from the content-addressed store, hash-verified

797// a required key's checker, wrapped where what the missing key expects or says
798// isn't what its value's checker does
799const writeRequired = (prop: Prop.Node, checker: string): string => {
800 const { description, message, c } = missingOf(prop)!
801 const held = checkerDescriptionOf(prop.value)
802 const said = combines(prop.value) ? saidByNode.get(prop.value) : undefined
803 if (message === undefined) {
804 return held === description && !said ?
805 checker
806 : writeCall("required", checker, JSON.stringify(description))
807 }
808 // what its value's checker says is its Type's message, not one the code's
809 if (held === description && said?.message === message && c === 1)
810 return checker
811 return writeCall(
812 "sayingMissing",
813 checker,
814 JSON.stringify(message),
815 // a message configured for the code is noted on the missing key's issue
816 c === 1 ? undefined : "runtime.codedIssue",
817 held === description ? undefined : JSON.stringify(description)
818 )
819}
820
821const writeStructure = (
822 js: CombinatorCompiler,

Callers 1

writeStructureFunction · 0.85

Calls 5

checkerDescriptionOfFunction · 0.85
combinesFunction · 0.85
writeCallFunction · 0.85
missingOfFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected