import type Ajv from 'ajv'; import type { Options } from 'ajv'; import type { JSONSchema, JSONSchemaDefinitions, Validator } from '../../types'; import { ValidationSeverity } from '../../types.js'; export interface AjvValidatorOptions { /** * The JSON schema to validate (required). */ schema: JSONSchema; /** * An object containing JSON Schema definitions which can be referenced using $ref. */ schemaDefinitions?: JSONSchemaDefinitions; /** * Optional extra options for Ajv. */ ajvOptions?: Options; /** * An optional callback function allowing to apply additional configuration on the provided Ajv instance, or return * your own Ajv instance and ignore the provided one. */ onCreateAjv?: (ajv: Ajv) => Ajv | void; /** * The severity of the validation error. * * @default ValidationSeverity.warning */ errorSeverity?: ValidationSeverity; } /** * Create a JSON Schema validator powered by Ajv. */ export declare function createAjvValidator(options: AjvValidatorOptions): Validator; /** * Create a JSON Schema validator powered by Ajv. * * Same as `createAjvValidator`, but allows for remote schema resolution through `ajvOptions`'s `loadSchema(uri)` * function. * * Note that `ajvOptions.loadSchema` *must* be set, or Ajv throws an error on initialization! * * ### Example * * const validate = await createAjvValidatorAsync({ * schema: { * $ref: '/schema.json' * }, * ajvOptions: { * loadSchema(uri) { * return fetch(uri).then((res) => res.json()) * } * } * }) */ export declare function createAjvValidatorAsync(options: AjvValidatorOptions): Promise;