Merge pull request #8681 from j-sheppard/master

Joi: change any.when options - is: attribute to type any
This commit is contained in:
Masahiro Wakame
2016-03-27 01:28:04 +09:00
2 changed files with 8 additions and 8 deletions
+2 -2
View File
@@ -97,9 +97,9 @@ uriOpts = {scheme: expArr};
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var whenOpts: Joi.WhenOptions = null;
var whenOpts: Joi.WhenOptions<any> = null;
whenOpts = {is: schema};
whenOpts = {is: x};
whenOpts = {is: schema, then: schema};
whenOpts = {is: schema, otherwise: schema};
+6 -6
View File
@@ -95,11 +95,11 @@ declare module 'joi' {
scheme ?: string | RegExp | Array<string | RegExp>;
}
export interface WhenOptions {
export interface WhenOptions<T> {
/**
* the required condition joi type.
*/
is: Schema;
is: T;
/**
* the alternative schema type if the condition is true. Required if otherwise is missing.
*/
@@ -269,8 +269,8 @@ declare module 'joi' {
/**
* Converts the type into an alternatives type where the conditions are merged into the type definition where:
*/
when(ref: string, options: WhenOptions): AlternativesSchema;
when(ref: Reference, options: WhenOptions): AlternativesSchema;
when<U>(ref: string, options: WhenOptions<U>): AlternativesSchema;
when<U>(ref: Reference, options: WhenOptions<U>): AlternativesSchema;
/**
* Overrides the key name in error messages.
@@ -691,8 +691,8 @@ declare module 'joi' {
export interface AlternativesSchema extends AnySchema<FunctionSchema> {
try(schemas: Schema[]): AlternativesSchema;
when(ref: string, options: WhenOptions): AlternativesSchema;
when(ref: Reference, options: WhenOptions): AlternativesSchema;
when<T>(ref: string, options: WhenOptions<T>): AlternativesSchema;
when<T>(ref: Reference, options: WhenOptions<T>): AlternativesSchema;
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---