MCPcopy
hub / github.com/arktypeio/arktype / parseObject

Function parseObject

ark/type/parser/definition.ts:77–105  ·  view source on GitHub ↗
(def: object, ctx: BaseParseContext)

Source from the content-addressed store, hash-verified

75}
76
77export const parseObject = (def: object, ctx: BaseParseContext): BaseRoot => {
78 const objectKind = objectKindOf(def)
79 switch (objectKind) {
80 case undefined:
81 if (hasArkKind(def, "root")) return def
82 if ("~standard" in def) return parseStandardSchema(def as never, ctx)
83 return parseObjectLiteral(def as Dict, ctx)
84 case "Array":
85 return parseTuple(def as array, ctx)
86 case "RegExp":
87 return ctx.$.node(
88 "intersection",
89 {
90 domain: "string",
91 pattern: def as RegExp
92 },
93 { prereduced: true }
94 )
95 case "Function": {
96 const resolvedDef = isThunk(def) ? def() : def
97 if (hasArkKind(resolvedDef, "root")) return resolvedDef
98 return throwParseError(writeBadDefinitionTypeMessage("Function"))
99 }
100 default:
101 return throwParseError(
102 writeBadDefinitionTypeMessage(objectKind ?? printable(def))
103 )
104 }
105}
106
107const parseStandardSchema = (
108 def: StandardSchemaV1,

Callers 1

parseInnerDefinitionFunction · 0.85

Calls 10

objectKindOfFunction · 0.90
hasArkKindFunction · 0.90
parseObjectLiteralFunction · 0.90
isThunkFunction · 0.90
throwParseErrorFunction · 0.90
printableFunction · 0.90
parseStandardSchemaFunction · 0.85
parseTupleFunction · 0.85
nodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…