Skip to content

Commit

Permalink
chore: export ajv type
Browse files Browse the repository at this point in the history
  • Loading branch information
k0stik committed Feb 16, 2024
1 parent fa660c7 commit b492f47
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/js/utils/ajv.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {} from "ajv"; // @see https://github.com/microsoft/TypeScript/issues/47663
import Ajv, { SchemaObject } from "ajv";
import { AnyValidateFunction } from "ajv/dist/core";

import { mapObjectDeep } from "../esse/schemaUtils";
import { JSONSchema } from "../esse/utils";
Expand Down Expand Up @@ -62,7 +63,10 @@ function getAjvInstance({ clean, coerceTypes }: AjvInstanceOptions) {
return ajvValidator;
}

export function getValidator(jsonSchema: SchemaObject, { clean, coerceTypes }: AjvInstanceOptions) {
export function getValidator(
jsonSchema: SchemaObject,
{ clean, coerceTypes }: AjvInstanceOptions,
): AnyValidateFunction {
const schemaKey = jsonSchema.$id as string;
const ajv = getAjvInstance({ clean, coerceTypes });
let validate = ajv.getSchema(schemaKey);
Expand Down

0 comments on commit b492f47

Please sign in to comment.