Skip to content

path-related methods (with(), nand()...) broken when applied on func()` #1665

@feugy

Description

@feugy

Context

  • node version: 8~10
  • joi version: 14.2.0
  • environment: node
  • used with: standalone
  • any other relevant information: worked with joi@13.0.0, seems to have been introduced with 14.0.0, and still failing with 14.2.0

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

I'm validating extra keys attached to functions (which I reckon, is quite weird from the start 😅).

const joi = require('joi')
const schema = joi.func().keys({
  a: joi.string(),
  b: joi.string()
}).with('a', 'b')

const fct = () => {}
fct.a = 'hello'
// fct.b = 'world!'

joi.assert(fct, schema, 'Error prefix')

Which result you had ?

AssertionError: Invalid segment b in reach path b

see it live

What did you expect ?

Error: Error prefix "a" missing required peer "b"

see it live

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