Skip to content

"ExternalValidationFunction" type is missing "helpers" parameter in index.d.ts #2605

@bromy

Description

@bromy

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: 14.16.0
  • module version with issue: 17.4.0
  • last module version without issue:
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): typescript
  • any other relevant information:

What are you trying to achieve or the steps to reproduce?

// using an external method in a TypeScript project
const isValidUser = async (value: any, helpers: any): Promise<any> { ... }
const userSchema = Joi.string().external(isValidUser)

What was the result you got?

Argument of type '(value: any, helpers: any) => Promise<any>' is not assignable to parameter of type 'ExternalValidationFunction'.

What result did you expect?

The ExternalValidationFunction type supports the helpers parameter as indicated in the documentation, even when used with TypeScript. At the least, the typing should probably be:

type ExternalValidationFunction = (value: any, helpers: any) => Promise<any>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug or defecttypesTypeScript type definitions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions