diff --git a/types/joi/index.d.ts b/types/joi/index.d.ts index 8959299a0c..c37e1602d5 100644 --- a/types/joi/index.d.ts +++ b/types/joi/index.d.ts @@ -854,26 +854,20 @@ export interface AlternativesSchema extends AnySchema { when(ref: Reference, options: WhenOptions): AlternativesSchema; } -export interface Terms { - value: any; - state: State; - options: ValidationOptions; -} - -export interface Rules { +export interface Rules

{ name: string; - params?: SchemaMap; - setup?: (this: AnySchema>, description: { [key: string]: any }) => AnySchema> | void; - validate?: (this: AnySchema>, params: { [key: string]: any }, value: any, state: State, options: ValidationOptions) => Err | undefined; - description?: string | Function; + params?: { [key in keyof P]: SchemaLike }; + setup?: (this: Schema, params: P) => Schema | void; + validate?: (this: Schema, params: P, value: any, state: State, options: ValidationOptions) => Err | R; + description?: string | ((params: P) => string); } export interface Extension { name: string; base?: Schema; - pre?: (this: AnySchema>, params: { [key: string]: any }, value: any, state: State, options: ValidationOptions) => Err | void; + pre?: (this: Schema, value: any, state: State, options: ValidationOptions) => Err | R; language?: LanguageRuleOptions; - describe?: (this: AnySchema>, description: Description) => Description; + describe?: (this: Schema, description: Description) => Description; rules?: Rules[]; } diff --git a/types/joi/joi-tests.ts b/types/joi/joi-tests.ts index b89ed2b038..5e57b9732c 100644 --- a/types/joi/joi-tests.ts +++ b/types/joi/joi-tests.ts @@ -919,6 +919,7 @@ const Joi3 = Joi.extend({ asd: 'must be exactly asd(f)', }, pre(value, state, options) { + return value; }, describe(description) { return description;