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

Function parseNodeSchema

ark/schema/parseSchema.ts:204–222  ·  view source on GitHub ↗
(
	kind: kind,
	schema: unknown,
	$: BaseScope,
	opts?: BaseParseOptions
)

Source from the content-addressed store, hash-verified

202): BaseRoot => parseNodeSchema(schemaKindOf(schema), schema, $, opts)
203
204export const parseNodeSchema = <kind extends NodeKind>(
205 kind: kind,
206 schema: unknown,
207 $: BaseScope,
208 opts?: BaseParseOptions
209): nodeOfKind<reducibleKindOf<kind>> => {
210 // a sequence's schema may be its variadic element
211 if (isNode(schema) && !(kind === "sequence" && schema.isRoot())) {
212 return $.node(
213 kind,
214 (schema.isRoot() ? schema.internal : schema) as never,
215 opts
216 ) as never
217 }
218 const input = readers[kind](schema, $, opts)
219 return isNode(input) ?
220 ($.node(input.kind, input as never, opts) as never)
221 : ($.node(kind, withPrefixedMeta(input as dict) as never, opts) as never)
222}
223
224export const schemaKindOf = <kind extends RootKind = RootKind>(
225 schema: unknown,

Callers 3

parseSchemaFunction · 0.85
parseSchema.tsFile · 0.85
addConstraintsFunction · 0.85

Calls 3

isNodeFunction · 0.90
withPrefixedMetaFunction · 0.85
nodeMethod · 0.80

Tested by

no test coverage detected