joi: add missing 'alt' method

This commit is contained in:
Young Rok Kim
2017-09-24 01:57:04 +09:00
parent 040a0eb7c5
commit d3a7b32ced
2 changed files with 15 additions and 2 deletions

10
types/joi/index.d.ts vendored
View File

@@ -551,7 +551,7 @@ export interface StringSchema extends AnySchema {
* Requires the string value to be a valid GUID.
*/
guid(options?: GuidOptions): this;
/**
* Alias for `guid` -- Requires the string value to be a valid GUID
*/
@@ -962,10 +962,15 @@ export function string(): StringSchema;
/**
* Generates a type that will match one of the provided alternative schemas
*/
export function alternatives(): AlternativesSchema;
export function alternatives(types: SchemaLike[]): AlternativesSchema;
export function alternatives(...types: SchemaLike[]): AlternativesSchema;
/**
* Alias for `alternatives`
*/
export function alt(types: SchemaLike[]): AlternativesSchema;
export function alt(...types: SchemaLike[]): AlternativesSchema;
/**
* Generates a placeholder schema for a schema that you would provide with the fn.
* Supports the same methods of the any() type.
@@ -1031,3 +1036,4 @@ export function extend(extention: Extension): any;
* Returns a plain object representing the schema's rules and properties
*/
export function describe(schema: Schema): Description;

View File

@@ -830,6 +830,13 @@ schema = Joi.alternatives().try(schema, schema);
schema = Joi.alternatives(schemaArr);
schema = Joi.alternatives(schema, anySchema, boolSchema);
schema = Joi.alt();
schema = Joi.alt().try(schemaArr);
schema = Joi.alt().try(schema, schema);
schema = Joi.alt(schemaArr);
schema = Joi.alt(schema, anySchema, boolSchema);
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
schema = Joi.lazy(() => schema)