Skip to content

Cannot validate an array with 'constructor' as unique entry #1476

@Piwaii

Description

@Piwaii

Context

  • node version: 8.9.4
  • joi version: 13.1.2
  • environment (node, browser): node
  • used with (hapi, standalone, ...):
  • any other relevant information:

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

I want to validate arrays with at least one string item and the string is unique in the array.
So I use :

joi.validate(['item1', 'item2'], joi.array().items(joi.string()).min(1).unique()
    .required())

Which result you had ?

It works fine but I have an array to check that is : ['constructor'] and it throw me a "non unique" error

Error: "value" position 0 contains a duplicate value

What did you expect ?

To validate my array

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions