mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
Merge pull request #9119 from spiffytech/master
Joi.alternatives bugfixes
This commit is contained in:
@@ -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
6
joi/joi.d.ts
vendored
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user