From 52d30d8cf99b163c76912da0e2f2e1df09fbd141 Mon Sep 17 00:00:00 2001
From: Pavel Ivanov
Date: Wed, 19 Apr 2017 11:37:41 +0300
Subject: [PATCH] Update type definition for ValidationOptions interface
- According to the docs it can be an object as well
---
types/joi/index.d.ts | 10 +++++++---
types/joi/joi-tests.ts | 3 +++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/types/joi/index.d.ts b/types/joi/index.d.ts
index 4fe2ed1282..7030ce4fb2 100644
--- a/types/joi/index.d.ts
+++ b/types/joi/index.d.ts
@@ -1,6 +1,6 @@
// Type definitions for joi v10.0.0
// Project: https://github.com/hapijs/joi
-// Definitions by: Bart van der Schoor , Laurence Dougal Myers , Christopher Glantschnig , David Broder-Rodgers , Gael Magnan de Bornier , Rytis Alekna
+// Definitions by: Bart van der Schoor , Laurence Dougal Myers , Christopher Glantschnig , David Broder-Rodgers , Gael Magnan de Bornier , Rytis Alekna , Pavel Ivanov
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TODO express type of Schema in a type-parameter (.default, .valid, .example etc)
@@ -25,9 +25,13 @@ export interface ValidationOptions {
*/
skipFunctions?: boolean;
/**
- * when true, unknown keys are deleted (only when value is an object). Defaults to false.
+ * remove unknown elements from objects and arrays. Defaults to false
+ * - when true, all unknown elements will be removed
+ * - when an object:
+ * - arrays - set to true to remove unknown items from arrays.
+ * - objects - set to true to remove unknown keys from objects
*/
- stripUnknown?: boolean;
+ stripUnknown?: boolean | {arrays: boolean} | {objects: boolean} | {arrays: boolean; objects: boolean};
/**
* overrides individual error messages. Defaults to no override ({}).
*/
diff --git a/types/joi/joi-tests.ts b/types/joi/joi-tests.ts
index 4226fc4f6a..f35a124183 100644
--- a/types/joi/joi-tests.ts
+++ b/types/joi/joi-tests.ts
@@ -55,6 +55,9 @@ validOpts = {convert: bool};
validOpts = {allowUnknown: bool};
validOpts = {skipFunctions: bool};
validOpts = {stripUnknown: bool};
+validOpts = {stripUnknown: {arrays: bool}};
+validOpts = {stripUnknown: {objects: bool}};
+validOpts = {stripUnknown: {arrays: bool, objects: bool}};
validOpts = {language: bool};
validOpts = {presence: str};
validOpts = {context: obj};