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

Function schemaKindOf

ark/schema/parseSchema.ts:224–235  ·  view source on GitHub ↗
(
	schema: unknown,
	allowedKinds?: readonly kind[]
)

Source from the content-addressed store, hash-verified

222}
223
224export const schemaKindOf = <kind extends RootKind = RootKind>(
225 schema: unknown,
226 allowedKinds?: readonly kind[]
227): kind => {
228 const kind = discriminateRootKind(schema)
229 if (allowedKinds && !allowedKinds.includes(kind as never)) {
230 return throwParseError(
231 `Root of kind ${kind} should be one of ${allowedKinds}`
232 )
233 }
234 return kind as never
235}
236
237const discriminateRootKind = (schema: unknown): RootKind => {
238 if (hasArkKind(schema, "root")) {

Callers 1

parseSchemaFunction · 0.85

Calls 2

throwParseErrorFunction · 0.90
discriminateRootKindFunction · 0.85

Tested by

no test coverage detected