Skip to content

Consistently apply wrap setting #2330

@individual11

Description

@individual11

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: 12.16.0
  • module version with issue: 17.1.1
  • last module version without issue: n/a
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information: n/a

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

Using the errors.wrap property introduced in 17 I'm getting rid of the quotes, and it's working on everything I've seen so far, except when using the with rule. It puts the quotes back in. In the below code, if you change a value to 1, then it will throw the correct error formatting around the label of a, but if a is the correct format (i.e. string), then the with error will throw, showing the quote marks.

const test = Joi.object({
   a: Joi.string(),
}).with('a', 'b');

const { error } = test.validate({ a: 'test' }, { errors: { wrap: { label: '*' } } });
console.log(error.details[0].message);
// "a" missing required peer "b"

What was the result you got?

"a" missing required peer "b"

What result did you expect?

*a* missing required peer *b*

Metadata

Metadata

Assignees

Labels

bugBug or defectfeatureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions