UNPKG

1.42 kBTypeScriptView Raw
1export type JSONSchema4 = import("json-schema").JSONSchema4;
2export type JSONSchema6 = import("json-schema").JSONSchema6;
3export type JSONSchema7 = import("json-schema").JSONSchema7;
4export type ErrorObject = import("ajv").ErrorObject;
5export type Extend = {
6 formatMinimum?: string | undefined;
7 formatMaximum?: string | undefined;
8 formatExclusiveMinimum?: string | undefined;
9 formatExclusiveMaximum?: string | undefined;
10 link?: string | undefined;
11 undefinedAsNull?: boolean | undefined;
12};
13export type Schema = (JSONSchema4 | JSONSchema6 | JSONSchema7) & Extend;
14export type SchemaUtilErrorObject = ErrorObject & {
15 children?: Array<ErrorObject>;
16};
17export type PostFormatter = (
18 formattedError: string,
19 error: SchemaUtilErrorObject
20) => string;
21export type ValidationErrorConfiguration = {
22 name?: string | undefined;
23 baseDataPath?: string | undefined;
24 postFormatter?: PostFormatter | undefined;
25};
26/**
27 * @param {Schema} schema
28 * @param {Array<object> | object} options
29 * @param {ValidationErrorConfiguration=} configuration
30 * @returns {void}
31 */
32export function validate(
33 schema: Schema,
34 options: Array<object> | object,
35 configuration?: ValidationErrorConfiguration | undefined
36): void;
37export function enableValidation(): void;
38export function disableValidation(): void;
39export function needValidate(): boolean;
40import ValidationError from "./ValidationError";
41export { ValidationError };