UNPKG

@dpkit/core

Version:

Fast TypeScript data management framework built on top of the Data Package standard and Polars DataFrames

14 lines (12 loc) 457 B
import { AssertionError } from "../error/index.ts" import type { Descriptor } from "../general/index.ts" import type { Schema } from "./Schema.ts" import { validateSchema } from "./validate.ts" /** * Assert a Schema descriptor (JSON Object) against its profile */ export async function assertSchema(source: Descriptor | Schema) { const { schema, errors } = await validateSchema(source) if (!schema) throw new AssertionError(errors) return schema }