Merge pull request #9119 from spiffytech/master

Joi.alternatives bugfixes
This commit is contained in:
Mohamed Hegazy
2016-06-26 15:06:51 -07:00
committed by GitHub
2 changed files with 8 additions and 2 deletions

View File

@@ -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);

6
joi/joi.d.ts vendored
View File

@@ -729,6 +729,7 @@ declare module 'joi' {
export interface AlternativesSchema extends AnySchema<FunctionSchema> {
try(schemas: Schema[]): AlternativesSchema;
try(type1: Schema, type2: Schema, ...types: Schema[]): AlternativesSchema;
when<T>(ref: string, options: WhenOptions<T>): AlternativesSchema;
when<T>(ref: Reference, options: WhenOptions<T>): 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.