Skip to content

Extended Joi does not contain certain top-level functions #933

@joebalancio

Description

@joebalancio

Context

  • node version: 4.2.3
  • joi version: 9.0.0-6
  • environment (node, browser): node
  • used with (hapi, standalone, ...): standalone
  • any other relevant information:

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

  1. Extend Joi using joi.extend. See example below
  2. Top-level functions like .when and .disallow do not exist

I think this happens because Joi is cloned from Any whereas the Extended Joi is assigned the enumerable properties from Joi.

example

const Custom = Joi.extend({
  name: 'newType'
})
console.log(Custom.when) // undefined

Which result you had ?

The new type exists on the extended Joi, but the top-level functions like Joi.when and Joi.disallow do not exist.

What did you expect ?

I expected those functions to exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug or defect

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions