Closed
Description
It may be handy to be able to specify key-based uniqueness within an array of items.
Given the schema
{
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"key" : { "type" : "string" },
"value" : { "type" : "integer" }
}
},
"uniqueItems" : true
}
the instance
[ { "key" : 1, "value" : "value1" }, { "key" : 1, "value" : "value2" } ]
would pass. However, the user may want this to fail as the value of the key
property is repeated.
I propose a uniquenessKey
(or similar) keyword that would allow the author to specify a pointer to an object property that should be unique among all items within the array. This would update the above schema to
{
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"key" : { "type" : "string" },
"value" : { "type" : "integer" }
}
},
"uniquenessKey" : "#/key"
}
(The pointer would be resolved using the item in the array as the root.)
Metadata
Metadata
Assignees
Labels
No labels