Joi: support alternatives() without parameters. Fix alternatives() not returning interface with try() member.

This commit is contained in:
spiffytech
2016-04-26 13:00:27 -04:00
parent 310c247694
commit 42a3162e0b
2 changed files with 6 additions and 2 deletions

View File

@@ -732,6 +732,9 @@ namespace common {
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
schema = Joi.alternatives();
schema = Joi.alternatives().try(schemaArr);
schema = Joi.alternatives(schemaArr);
schema = Joi.alternatives(schema, anySchema, boolSchema);

5
joi/joi.d.ts vendored
View File

@@ -747,8 +747,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.