UNPKG

data-to-jsonschema-to-ts

Version:

Convert plain javascript objects to JSON Schema and TypeScript typings

17 lines 696 B
import { type ErrorObject } from "ajv"; /** * Compile a JSON Schema into a reusable validator function. * * The returned validator runs the data against the schema and reports * **all** failing constraints (not just the first). Compilation happens * once per call to this function; reuse the returned validator to avoid * recompiling. * * @param schema - JSON Schema to validate against. * @returns A function `(data) => { valid, errors? }`. `errors` is `undefined` on success. */ export declare function createJsonSchemaValidator(schema: object): (data: object | Array<any>) => { valid: boolean; errors?: ErrorObject[] | undefined | null; }; //# sourceMappingURL=index.d.ts.map