Skip to content

Joi valid fails, when ref is used with a stripped key. #831

@kevbook

Description

@kevbook

Joi valid fails, when ref is used with a stripped key. Maybe this is the expected behaviour. I'll let you decide.

  • node version: v4.2.1
  • joi version: ^0.8.5
  • environment (node, browser): node
  • used with (hapi, standalone, ...): standalone

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

var Joi = require('joi');

var schema = Joi.object({
  a: Joi.any().required().strip(),
  b: Joi.any().valid(Joi.ref('a'))
});
console.log(  schema.validate({ a: 1, b: 1 }) );

Which result you had ?

Error: child "b" fails because ["b" must be one of [ref:a]]

What did you expect ?

No error, and "a" should have been stripped. Value: { b: 1 }

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions