Skip to content

object.with and object.without throw error on $ prefixed keys #2226

@augnin

Description

@augnin

Support plan

  • which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise):
    Community

  • is this issue currently blocking your project? (yes/no):
    No

  • is this issue affecting a production system? (yes/no):
    No

Context

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

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

Confidence takes a json object with special purpose $-prefixed keys as input, using joi to validate it. I'm moving confidence store schema to joi v16 from v15. New implementation of methods such as object.with and object.without don't support $-prefixed keys or peers.

const schema = Joi.object().keys({
    $b: Joi.string(),
    $c: Joi.string()
}).without('$c', '$b');

What was the result you got?

Schema throws an error

Error: Non-value references cannot reference ancestors

What result did you expect?

handle $-prefixed keys

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions