diff --git a/types/joi/index.d.ts b/types/joi/index.d.ts index 0772c82fbe..26314637ad 100644 --- a/types/joi/index.d.ts +++ b/types/joi/index.d.ts @@ -162,7 +162,7 @@ export interface ValidationResult { } export interface SchemaMap { - [key: string]: Schema | SchemaMap | (Schema | SchemaMap)[]; + [key: string]: string | number | boolean | object | null | Schema | SchemaMap | (Schema | SchemaMap)[]; } export interface Schema extends AnySchema { @@ -575,20 +575,16 @@ export interface ArraySchema extends AnySchema { * * @param type - a joi schema object to validate each array item against. */ - items(...types: Schema[]): ArraySchema; - items(...types: SchemaMap[]): ArraySchema; - items(types: Schema[]): ArraySchema; - items(types: SchemaMap[]): ArraySchema; + items(...types: (Schema | SchemaMap)[]): ArraySchema; + items(types: (Schema | SchemaMap)[]): ArraySchema; /** * Lists the types in sequence order for the array values where: * @param type - a joi schema object to validate against each array item in sequence order. type can be an array of values, or multiple values can be passed as individual arguments. * If a given type is .required() then there must be a matching item with the same index position in the array. Errors will contain the number of items that didn't match. Any unmatched item having a label will be mentioned explicitly. */ - ordered(...types: Schema[]): ArraySchema; - ordered(...types: SchemaMap[]): ArraySchema; - ordered(types: Schema[]): ArraySchema; - ordered(types: SchemaMap[]): ArraySchema; + ordered(...types: (Schema | SchemaMap)[]): ArraySchema; + ordered(types: (Schema | SchemaMap)[]): ArraySchema; /** * Specifies the minimum number of items in the array. diff --git a/types/joi/joi-tests.ts b/types/joi/joi-tests.ts index fb0537f6f9..63b247bc98 100644 --- a/types/joi/joi-tests.ts +++ b/types/joi/joi-tests.ts @@ -181,6 +181,17 @@ schemaMap = { ], c: arrSchema }; +schemaMap = { + a: 1, + b: { + b1: '1', + b2: 2 + }, + c: [ + { c1: true }, + { c2: null } + ] +} // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- @@ -892,9 +903,9 @@ const Joi3 = Joi.extend({ language: { asd: 'must be exactly asd(f)', }, - pre (value, state, options) { + pre(value, state, options) { }, - describe (description) { + describe(description) { }, rules: [ { @@ -902,10 +913,10 @@ const Joi3 = Joi.extend({ params: { allowF: Joi.boolean().default(false), }, - setup (params) { + setup(params) { const fIsAllowed = params.allowF; }, - validate (params, value, state, options) { + validate(params, value, state, options) { if (value === 'asd' || params.allowF && value === 'asdf') { return value; }