Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding array.min() when using reach #1595

Closed
Nargonath opened this issue Sep 24, 2018 · 1 comment
Closed

Overriding array.min() when using reach #1595

Nargonath opened this issue Sep 24, 2018 · 1 comment
Assignees
Labels
breaking changes Change that can breaking existing code feature New functionality or improvement
Milestone

Comments

@Nargonath
Copy link
Member

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.

@Marsup Marsup self-assigned this Sep 24, 2018
@Marsup Marsup added request breaking changes Change that can breaking existing code labels Sep 24, 2018
@Marsup Marsup added this to the 14.0.0 milestone Sep 24, 2018
@Marsup
Copy link
Collaborator

Marsup commented Sep 24, 2018

Duplicate of #1127.

@Marsup Marsup closed this as completed Sep 24, 2018
@hueniverse hueniverse added feature New functionality or improvement and removed request labels Sep 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking changes Change that can breaking existing code feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

3 participants