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 2520caf
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 28 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
45 changes: 33 additions & 12 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.

Loading

0 comments on commit 2520caf

Please sign in to comment.