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

Function parseProperty

ark/type/parser/property.ts:39–57  ·  view source on GitHub ↗
(
	def: unknown,
	ctx: BaseParseContext
)

Source from the content-addressed store, hash-verified

37export type ParsedOptionalProperty = readonly [BaseRoot, "?"]
38
39export const parseProperty = (
40 def: unknown,
41 ctx: BaseParseContext
42): ParsedProperty => {
43 if (isArray(def)) {
44 if (def[1] === "=") {
45 assertTupleArity(def, "=", 3)
46 return [ctx.$.parseOwn(def[0], ctx), "=", def[2]]
47 }
48
49 if (def[1] === "?") {
50 assertTupleArity(def, "?", 2)
51 return [ctx.$.parseOwn(def[0], ctx), "?"]
52 }
53 }
54
55 // string-embedded defaults/optionals are handled by the string parser
56 return parseInnerDefinition(def, ctx)
57}
58
59export type validateProperty<def, keyKind extends ParsedKeyKind, $, args> =
60 // validateInnerDefinition returns any or never as is

Callers 2

parseTupleLiteralFunction · 0.90
parseObjectLiteralFunction · 0.90

Calls 3

assertTupleArityFunction · 0.90
parseInnerDefinitionFunction · 0.90
parseOwnMethod · 0.45

Tested by

no test coverage detected