Skip to content

Commit

Permalink
fix: typescript definitions (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Oct 15, 2019
1 parent b98e06c commit f38158d
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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<ErrorObject>,
errors: Array<SchemaUtilErrorObject>,
schema: Schema,
configuration?: Partial<ValidationErrorConfiguration>
);

name: string;
errors: Array<ErrorObject>;
errors: Array<SchemaUtilErrorObject>;
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> | object,
configuration?: Partial<SchemaUtils.ValidationErrorConfiguration>
): void;
Expand Down

0 comments on commit f38158d

Please sign in to comment.