voxpupuli / json-schema

Ruby JSON Schema Validator
MIT License
1.52k stars 241 forks source link

Attribute uniqueItem: false should not trigger validation #461

Open hfabre opened 2 years ago

hfabre commented 2 years ago

Hi, I encounter a problem with json-schema. Given the following spec:

require "json-schema"

schema = {
  "type" => "object",
  "required" => ["target"],
  "properties" => {
    "target" => {
      "type" => "array",
      "items" => {},
      "uniqueItems" => false,
    }
  }
}

data = { "target" => [1, 1] }

JSON::Validator.fully_validate(schema, data)
# => ["The property '#/target' contained duplicated array values in schema 4d32e7eb-0393-5de4-81f2-37eecb8cc064"]

In my opinion and according to the json schema spec, it should validate only if set to true.