Skip to content

Commit f38158d

Browse files
fix: typescript definitions (#70)
1 parent b98e06c commit f38158d

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

index.d.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
11
import { JSONSchema4, JSONSchema6, JSONSchema7 } from 'json-schema';
22
import { ErrorObject } from 'ajv';
33

4-
type Schema = JSONSchema4 | JSONSchema6 | JSONSchema7;
5-
type PostFormatter = (formattedError: string, error: ErrorObject) => string;
6-
74
declare namespace SchemaUtils {
5+
type Schema = JSONSchema4 | JSONSchema6 | JSONSchema7;
6+
type SchemaUtilErrorObject = ErrorObject & {
7+
children?: SchemaUtilErrorObject[];
8+
};
9+
type PostFormatter = (
10+
formattedError: string,
11+
error: SchemaUtilErrorObject
12+
) => string;
13+
14+
interface ValidationErrorConfiguration {
15+
name: string;
16+
baseDataPath: string;
17+
postFormatter: PostFormatter;
18+
}
19+
820
class ValidationError extends Error {
921
constructor(
10-
errors: Array<ErrorObject>,
22+
errors: Array<SchemaUtilErrorObject>,
1123
schema: Schema,
1224
configuration?: Partial<ValidationErrorConfiguration>
1325
);
1426

1527
name: string;
16-
errors: Array<ErrorObject>;
28+
errors: Array<SchemaUtilErrorObject>;
1729
schema: Schema;
1830
headerName: string;
1931
baseDataPath: string;
2032
postFormatter: PostFormatter | null;
2133
message: string;
2234
}
23-
24-
interface ValidationErrorConfiguration {
25-
name: string;
26-
baseDataPath: string;
27-
postFormatter: PostFormatter;
28-
}
2935
}
3036

31-
declare var validate: {
37+
declare const validate: {
3238
(
33-
schema: Schema,
39+
schema: SchemaUtils.Schema,
3440
options: Array<object> | object,
3541
configuration?: Partial<SchemaUtils.ValidationErrorConfiguration>
3642
): void;

0 commit comments

Comments
 (0)