From bd0de57f3c3ace8d08f5ccc5b89ef5ae1966922c Mon Sep 17 00:00:00 2001 From: Ron Zeidman Date: Mon, 10 Oct 2016 16:02:41 +0300 Subject: [PATCH 1/4] Error object fix Source: https://github.com/hapijs/joi/blob/master/API.md#errors ## Errors Joi throws classical javascript `Error`s containing : - `name` - `'ValidationError'`. - `isJoi` - `true`. - `details` - an array of errors : - `message` - string with a description of the error. - `path` - dotted path to the key where the error happened. - `type` - type of the error. - `context` - object providing context of the error. - `annotate` - function that returns a string with an annotated version of the object pointing at the places where errors occured. - `_object` - the original object to validate. --- joi/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/joi/index.d.ts b/joi/index.d.ts index ece6bb6d62..0b2cf1e8cb 100644 --- a/joi/index.d.ts +++ b/joi/index.d.ts @@ -121,17 +121,17 @@ export interface IPOptions { } export interface ValidationError extends Error { - message: string; + isJoi: boolean; details: ValidationErrorItem[]; - simple(): string; - annotated(): string; + annotate(): string; + _object: any; } export interface ValidationErrorItem { message: string; type: string; path: string; - options?: ValidationOptions; + context?: any; } export interface ValidationResult { From db86a7a621d9fe465f433ab6cf89e91952ff1d32 Mon Sep 17 00:00:00 2001 From: Ron Zeidman Date: Mon, 10 Oct 2016 16:05:26 +0300 Subject: [PATCH 2/4] Update joi-tests.ts --- joi/joi-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/joi/joi-tests.ts b/joi/joi-tests.ts index eb0f147f78..557146cabc 100644 --- a/joi/joi-tests.ts +++ b/joi/joi-tests.ts @@ -125,7 +125,7 @@ validErrItem = { message: str, type: str, path: str, - options: validOpts + context: obj }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- From f116c1260178815885ad43ff7497f91abfb1fbc8 Mon Sep 17 00:00:00 2001 From: Ron Zeidman Date: Tue, 11 Oct 2016 09:47:42 +0300 Subject: [PATCH 3/4] Update index.d.ts Options does exist --- joi/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/joi/index.d.ts b/joi/index.d.ts index 0b2cf1e8cb..c192f49dd1 100644 --- a/joi/index.d.ts +++ b/joi/index.d.ts @@ -131,6 +131,7 @@ export interface ValidationErrorItem { message: string; type: string; path: string; + options?: ValidationOptions; context?: any; } From a388c6c5f9de3a3ba8afdf866a69e35e6ff44de2 Mon Sep 17 00:00:00 2001 From: Ron Zeidman Date: Tue, 11 Oct 2016 09:50:15 +0300 Subject: [PATCH 4/4] Update joi-tests.ts options does exist --- joi/joi-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/joi/joi-tests.ts b/joi/joi-tests.ts index 557146cabc..759be529ad 100644 --- a/joi/joi-tests.ts +++ b/joi/joi-tests.ts @@ -125,6 +125,7 @@ validErrItem = { message: str, type: str, path: str, + options: validOpts, context: obj };