diff --git a/index.d.ts b/index.d.ts index 86ea372..27b856b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,12 +1,16 @@ -import {JSONSchema4, JSONSchema6, JSONSchema7} from 'json-schema'; -import {ErrorObject} from 'ajv'; +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 { - class ValidateError extends Error { - constructor(errors: Array, schema: Schema, configuration?: Partial); + class ValidationError extends Error { + constructor( + errors: Array, + schema: Schema, + configuration?: Partial + ); name: string; errors: Array; @@ -17,16 +21,21 @@ declare namespace SchemaUtils { message: string; } - interface ValidateErrorConfiguration { - name: string, - baseDataPath: string, - postFormatter: PostFormatter + interface ValidationErrorConfiguration { + name: string; + baseDataPath: string; + postFormatter: PostFormatter; } } declare var validate: { - (schema: Schema, options: Array | object, configuration?: Partial): void; - ValidateError: typeof SchemaUtils.ValidateError -} + ( + schema: Schema, + options: Array | object, + configuration?: Partial + ): void; + ValidateError: typeof SchemaUtils.ValidationError; + ValidationError: typeof SchemaUtils.ValidationError; +}; export = validate; diff --git a/src/index.js b/src/index.js index 44b2c98..79e1ee8 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,8 @@ const validate = require('./validate'); -const validateError = require('./ValidationError'); +const ValidationError = require('./ValidationError'); module.exports = validate.default; -module.exports.ValidateError = validateError.default; +module.exports.ValidationError = ValidationError.default; + +// Todo remove this in next major release +module.exports.ValidateError = ValidationError.default; diff --git a/test/api.test.js b/test/api.test.js index b906feb..ca1f21e 100644 --- a/test/api.test.js +++ b/test/api.test.js @@ -6,6 +6,7 @@ describe('api', () => { it('should export validate and ValidateError', () => { expect(typeof schemaUtils).toBe('function'); expect(typeof schemaUtils.ValidateError).toBe('function'); + expect(typeof schemaUtils.ValidationError).toBe('function'); }); it('should work', () => {