diff --git a/index.d.ts b/index.d.ts index 27b856b..0ab1b99 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,36 +1,42 @@ import { JSONSchema4, JSONSchema6, JSONSchema7 } from 'json-schema'; import { ErrorObject } from 'ajv'; -type Schema = JSONSchema4 | JSONSchema6 | JSONSchema7; -type PostFormatter = (formattedError: string, error: ErrorObject) => string; - declare namespace SchemaUtils { + type Schema = JSONSchema4 | JSONSchema6 | JSONSchema7; + type SchemaUtilErrorObject = ErrorObject & { + children?: SchemaUtilErrorObject[]; + }; + type PostFormatter = ( + formattedError: string, + error: SchemaUtilErrorObject + ) => string; + + interface ValidationErrorConfiguration { + name: string; + baseDataPath: string; + postFormatter: PostFormatter; + } + class ValidationError extends Error { constructor( - errors: Array, + errors: Array, schema: Schema, configuration?: Partial ); name: string; - errors: Array; + errors: Array; schema: Schema; headerName: string; baseDataPath: string; postFormatter: PostFormatter | null; message: string; } - - interface ValidationErrorConfiguration { - name: string; - baseDataPath: string; - postFormatter: PostFormatter; - } } -declare var validate: { +declare const validate: { ( - schema: Schema, + schema: SchemaUtils.Schema, options: Array | object, configuration?: Partial ): void;