diff --git a/joi/joi-tests.ts b/joi/joi-tests.ts index e5bda7874c..37848203df 100644 --- a/joi/joi-tests.ts +++ b/joi/joi-tests.ts @@ -743,6 +743,10 @@ namespace common { // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- +schema = Joi.alternatives(); +schema = Joi.alternatives().try(schemaArr); +schema = Joi.alternatives().try(schema, schema); + schema = Joi.alternatives(schemaArr); schema = Joi.alternatives(schema, anySchema, boolSchema); diff --git a/joi/joi.d.ts b/joi/joi.d.ts index 72a1af9425..3ba51d7383 100644 --- a/joi/joi.d.ts +++ b/joi/joi.d.ts @@ -729,6 +729,7 @@ declare module 'joi' { export interface AlternativesSchema extends AnySchema { try(schemas: Schema[]): AlternativesSchema; + try(type1: Schema, type2: Schema, ...types: Schema[]): AlternativesSchema; when(ref: string, options: WhenOptions): AlternativesSchema; when(ref: Reference, options: WhenOptions): AlternativesSchema; } @@ -812,8 +813,9 @@ declare module 'joi' { /** * Generates a type that will match one of the provided alternative schemas */ - export function alternatives(types: Schema[]): Schema; - export function alternatives(type1: Schema, type2: Schema, ...types: Schema[]): Schema; + export function alternatives(): AlternativesSchema; + export function alternatives(types: Schema[]): AlternativesSchema; + export function alternatives(type1: Schema, type2: Schema, ...types: Schema[]): AlternativesSchema; /** * Validates a value using the given schema and options.