Skip to content

Commit

Permalink
feat: add export ErrorObject (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
budarin committed Sep 17, 2022
1 parent 5af89d3 commit b014513
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type ValidatorCompiler = (

export declare function ValidatorSelector(): ValidatorCompiler;

export type { Options } from "ajv";
export type { Options, ErrorObject } from "ajv";
export type Ajv = _ajv;
export default ValidatorSelector;
export { StandaloneValidator };
export { StandaloneValidator };
13 changes: 12 additions & 1 deletion test/types/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AnySchemaObject } from "ajv";
import { expectAssignable, expectType } from "tsd";
import ValidatorSelector, { ValidatorCompiler, StandaloneValidator, RouteDefinition } from "../..";
import ValidatorSelector, { ValidatorCompiler, StandaloneValidator, RouteDefinition, ErrorObject } from "../..";

const compiler = ValidatorSelector();
expectType<ValidatorCompiler>(compiler);
Expand All @@ -20,3 +21,13 @@ const writer = StandaloneValidator({
},
});
expectType<ValidatorCompiler>(writer);

expectType<unknown>(({} as ErrorObject).data)
expectType<string>(({} as ErrorObject).instancePath)
expectType<string>(({} as ErrorObject).keyword)
expectType<string | undefined>(({} as ErrorObject).message)
expectType<Record<string, any>>(({} as ErrorObject).params)
expectType<AnySchemaObject | undefined>(({} as ErrorObject).parentSchema)
expectType<string | undefined>(({} as ErrorObject).propertyName)
expectType<unknown>(({} as ErrorObject).schema)
expectType<string>(({} as ErrorObject).schemaPath)

0 comments on commit b014513

Please sign in to comment.