Skip to content

Overriding array.min() when using reach #1595

@Nargonath

Description

@Nargonath

Context

  • node version: 10.11.0 and 8.12.0
  • joi version: 13.6.0
  • environment (node, browser): node
  • used with (hapi, standalone, ...): hapi
  • any other relevant information:

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

const Joi = require("joi");

const baseArray = Joi.object().keys({
  key: Joi.array()
    .min(2)
    .required()
    .items(Joi.object().keys({ a: Joi.string() }))
});
const extended = baseArray.keys({ key: Joi.reach(baseArray, "key").min(1) });

const value = { key: [{ a: "toto" }] };
await Joi.validate(value, extended);

Runkit to reproduce the problem.

Which result you had ?

It throws saying that the key array expects 2 items whereas I overrided it for a .min(1).

What did you expect ?

I was expecting the override to work and the validation to pass.

Metadata

Metadata

Assignees

Labels

breaking changesChange that can breaking existing codefeatureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions