Skip to content

Wrong State['path'] type #2730

@z1ne2wo

Description

@z1ne2wo

Context

  • node version: 14.18.1
  • module version with issue: 17.5.0
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone

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

The following code will output:

[ 'a', 'b', 0, 'c' ]
[ 'a', 'b', 1, 'c' ]

Code:

Joi
    .object({
        a: Joi.object({
            b: Joi.array().items(Joi.object({
                c: Joi.custom((value, helpers) => {
                    console.log(helpers.state.path);
                    return value;
                })
            }))
        })
    })
    .validate({ a: { b: [{ c: '1' }, { c: '2' }] } });

What was the result you got?

helpers.state.path has type string | undefined (defined here)

What result did you expect?

helpers.state.path has type (string | number)[] | undefined

Metadata

Metadata

Assignees

Labels

typesTypeScript type definitions

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions