From f38158d6d040e2c701622778ae8122fb26a4f990 Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Tue, 15 Oct 2019 18:44:33 +0300 Subject: [PATCH] fix: typescript definitions (#70) --- index.d.ts | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) 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;