Skip to content

Commit a435b79

Browse files
fix: typescript definition and export naming (#69)
1 parent 0d12259 commit a435b79

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

index.d.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
import {JSONSchema4, JSONSchema6, JSONSchema7} from 'json-schema';
2-
import {ErrorObject} from 'ajv';
1+
import { JSONSchema4, JSONSchema6, JSONSchema7 } from 'json-schema';
2+
import { ErrorObject } from 'ajv';
33

44
type Schema = JSONSchema4 | JSONSchema6 | JSONSchema7;
55
type PostFormatter = (formattedError: string, error: ErrorObject) => string;
66

77
declare namespace SchemaUtils {
8-
class ValidateError extends Error {
9-
constructor(errors: Array<ErrorObject>, schema: Schema, configuration?: Partial<ValidateErrorConfiguration>);
8+
class ValidationError extends Error {
9+
constructor(
10+
errors: Array<ErrorObject>,
11+
schema: Schema,
12+
configuration?: Partial<ValidationErrorConfiguration>
13+
);
1014

1115
name: string;
1216
errors: Array<ErrorObject>;
@@ -17,16 +21,21 @@ declare namespace SchemaUtils {
1721
message: string;
1822
}
1923

20-
interface ValidateErrorConfiguration {
21-
name: string,
22-
baseDataPath: string,
23-
postFormatter: PostFormatter
24+
interface ValidationErrorConfiguration {
25+
name: string;
26+
baseDataPath: string;
27+
postFormatter: PostFormatter;
2428
}
2529
}
2630

2731
declare var validate: {
28-
(schema: Schema, options: Array<object> | object, configuration?: Partial<SchemaUtils.ValidateErrorConfiguration>): void;
29-
ValidateError: typeof SchemaUtils.ValidateError
30-
}
32+
(
33+
schema: Schema,
34+
options: Array<object> | object,
35+
configuration?: Partial<SchemaUtils.ValidationErrorConfiguration>
36+
): void;
37+
ValidateError: typeof SchemaUtils.ValidationError;
38+
ValidationError: typeof SchemaUtils.ValidationError;
39+
};
3140

3241
export = validate;

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const validate = require('./validate');
2-
const validateError = require('./ValidationError');
2+
const ValidationError = require('./ValidationError');
33

44
module.exports = validate.default;
5-
module.exports.ValidateError = validateError.default;
5+
module.exports.ValidationError = ValidationError.default;
6+
7+
// Todo remove this in next major release
8+
module.exports.ValidateError = ValidationError.default;

test/api.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ describe('api', () => {
66
it('should export validate and ValidateError', () => {
77
expect(typeof schemaUtils).toBe('function');
88
expect(typeof schemaUtils.ValidateError).toBe('function');
9+
expect(typeof schemaUtils.ValidationError).toBe('function');
910
});
1011

1112
it('should work', () => {

0 commit comments

Comments
 (0)