Skip to content

Commit

Permalink
Add error type and field name as properties of ValidationError
Browse files Browse the repository at this point in the history
  • Loading branch information
ls-remy-jeancolas authored and RemyJeancolas committed Aug 3, 2022
1 parent b0eeacc commit 7f10ba7
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 31 deletions.
11 changes: 10 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ export interface PropertyCheckParams {
onFailure?: onFailure;
}

export class ValidationError extends Error {}
export declare enum ValidationErrorType {
NullValue = "null",
MissingField = "missing",
InvalidType = "invalid"
}

export class ValidationError extends Error {
public readonly field: string | undefined;
public readonly errorType: ValidationErrorType;
}

export function TypesCheck(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): any;
export function TypeCheck(type: any): any;
Expand Down
47 changes: 32 additions & 15 deletions js/TypeChecker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/TypeChecker.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
"tslint-microsoft-contrib": "^5.2.1",
"typescript": "^3.9.10"
},
"typings": "index.d.ts"
"typings": "index.ts"
}
Loading

0 comments on commit 7f10ba7

Please sign in to comment.