Skip to content

array() should set a specific detail.path #202

@joeybaker

Description

@joeybaker

When an error is found in a nested value of an array, it would be great if the details.path gave the full path to the error instead of just the top level path.

// joi schema

  products: joi.array().includes(joi.object({
    plans: joi.array().includes(joi.object({
      features: joi.array().includes(joi.object({
        value: joi.number()
      }))
    }))
// results
details: {

message: 'the products array value in position 0 fails because the plans array value in position 0 fails because the features array value in position 0 fails because the value of value must be a number'
, path: 'products' // ← this should be `products[0].plans[0].features[0].value`

}

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