From 166d1a8b350c53505f101442063d535f38e89aed Mon Sep 17 00:00:00 2001 From: Matthew Bull Date: Wed, 6 Dec 2017 20:38:10 +0000 Subject: [PATCH 1/2] Joi.extend can be called with arrays --- types/joi/index.d.ts | 3 ++- types/joi/joi-tests.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/types/joi/index.d.ts b/types/joi/index.d.ts index cc13a9deca..3cfe54d9f6 100644 --- a/types/joi/index.d.ts +++ b/types/joi/index.d.ts @@ -1071,7 +1071,8 @@ export function reach(schema: ObjectSchema, path: string): T; /** * Creates a new Joi instance customized with the extension(s) you provide included. */ -export function extend(extention: Extension): any; +export function extend(extention: Extension|Extension[]): any; +export function extend(...extentions: (Extension|Extension[])[]): any; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- diff --git a/types/joi/joi-tests.ts b/types/joi/joi-tests.ts index 34fc5271e0..6d2d12efb6 100644 --- a/types/joi/joi-tests.ts +++ b/types/joi/joi-tests.ts @@ -970,6 +970,12 @@ const Joi3 = Joi.extend({ ], }); +const Joi4 = Joi.extend([{ name: '', base: schema }, { name: '', base: schema }]); + +const Joi5 = Joi.extend({ name: '', base: schema }, { name: '', base: schema }); + +const Joi6 = Joi.extend({ name: '', base: schema }, [{ name: '', base: schema }, { name: '', base: schema }]); + // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- const defaultsJoi = Joi.defaults((schema) => { From 5ee6ff2ab51696b9dfa9eec0b168bf882e611720 Mon Sep 17 00:00:00 2001 From: Matthew Bull Date: Mon, 11 Dec 2017 23:54:17 +0000 Subject: [PATCH 2/2] Applied changes from feedback --- types/joi/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/joi/index.d.ts b/types/joi/index.d.ts index 3cfe54d9f6..7a41f238de 100644 --- a/types/joi/index.d.ts +++ b/types/joi/index.d.ts @@ -1071,8 +1071,7 @@ export function reach(schema: ObjectSchema, path: string): T; /** * Creates a new Joi instance customized with the extension(s) you provide included. */ -export function extend(extention: Extension|Extension[]): any; -export function extend(...extentions: (Extension|Extension[])[]): any; +export function extend(extension: Extension|Extension[], ...extensions: (Extension|Extension[])[]): any; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---