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

At least one of arrays nodes must be filled #2694

Open
innovaweb-dev opened this issue Nov 4, 2021 · 0 comments
Open

At least one of arrays nodes must be filled #2694

innovaweb-dev opened this issue Nov 4, 2021 · 0 comments

Comments

@innovaweb-dev
Copy link

Support plan

  • is this issue currently blocking your project? (yes/no): NO
  • is this issue affecting a production system? (yes/no): NO

Context

  • node version: v14.17.0
  • module version: 17.4.2
  • environment (e.g. node, browser, native): node and browser
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information:

How can we help?

At least one of arrays nodes must be filled, If all arrays nodes are empty, abort validation.

const validator = Joi.array().items(Joi.object({
    day: Joi.string().required(),
    nodes: Joi.array().items(Joi.array().items(Joi.number()).length(2))
})).length(7)

//not valid
const week = [
    {day: 'monday', nodes: []},
    {day: 'tuesday', nodes: []},
    {day: 'wednessday', nodes: []},
]

//valid
const week = [
    {day: 'monday', nodes: [[5,7]]},
    {day: 'tuesday', nodes: []},
    {day: 'wednessday', nodes: []},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant