From 7766f486d611a48d23a5c187435a877976a8e5ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Wed, 3 Jun 2020 04:57:53 +0300 Subject: [PATCH] Improve uniqueItems validation There are poor implementations which are triggered by these two checks --- tests/draft2019-09/uniqueItems.json | 12 +++++++++++- tests/draft4/uniqueItems.json | 12 +++++++++++- tests/draft6/uniqueItems.json | 12 +++++++++++- tests/draft7/uniqueItems.json | 12 +++++++++++- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/tests/draft2019-09/uniqueItems.json b/tests/draft2019-09/uniqueItems.json index bbd7ef3a..fb1ddb5c 100644 --- a/tests/draft2019-09/uniqueItems.json +++ b/tests/draft2019-09/uniqueItems.json @@ -96,13 +96,23 @@ }, { "description": "unique heterogeneous types are valid", - "data": [{}, [1], true, null, 1], + "data": [{}, [1], true, null, 1, "{}"], "valid": true }, { "description": "non-unique heterogeneous types are invalid", "data": [{}, [1], true, null, {}, 1], "valid": false + }, + { + "description": "different objects are unique", + "data": [{"a": 1, "b": 2}, {"a": 2, "b": 1}], + "valid": true + }, + { + "description": "objects are non-unique despite key order", + "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}], + "valid": false } ] }, diff --git a/tests/draft4/uniqueItems.json b/tests/draft4/uniqueItems.json index bbd7ef3a..fb1ddb5c 100644 --- a/tests/draft4/uniqueItems.json +++ b/tests/draft4/uniqueItems.json @@ -96,13 +96,23 @@ }, { "description": "unique heterogeneous types are valid", - "data": [{}, [1], true, null, 1], + "data": [{}, [1], true, null, 1, "{}"], "valid": true }, { "description": "non-unique heterogeneous types are invalid", "data": [{}, [1], true, null, {}, 1], "valid": false + }, + { + "description": "different objects are unique", + "data": [{"a": 1, "b": 2}, {"a": 2, "b": 1}], + "valid": true + }, + { + "description": "objects are non-unique despite key order", + "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}], + "valid": false } ] }, diff --git a/tests/draft6/uniqueItems.json b/tests/draft6/uniqueItems.json index bbd7ef3a..fb1ddb5c 100644 --- a/tests/draft6/uniqueItems.json +++ b/tests/draft6/uniqueItems.json @@ -96,13 +96,23 @@ }, { "description": "unique heterogeneous types are valid", - "data": [{}, [1], true, null, 1], + "data": [{}, [1], true, null, 1, "{}"], "valid": true }, { "description": "non-unique heterogeneous types are invalid", "data": [{}, [1], true, null, {}, 1], "valid": false + }, + { + "description": "different objects are unique", + "data": [{"a": 1, "b": 2}, {"a": 2, "b": 1}], + "valid": true + }, + { + "description": "objects are non-unique despite key order", + "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}], + "valid": false } ] }, diff --git a/tests/draft7/uniqueItems.json b/tests/draft7/uniqueItems.json index bbd7ef3a..fb1ddb5c 100644 --- a/tests/draft7/uniqueItems.json +++ b/tests/draft7/uniqueItems.json @@ -96,13 +96,23 @@ }, { "description": "unique heterogeneous types are valid", - "data": [{}, [1], true, null, 1], + "data": [{}, [1], true, null, 1, "{}"], "valid": true }, { "description": "non-unique heterogeneous types are invalid", "data": [{}, [1], true, null, {}, 1], "valid": false + }, + { + "description": "different objects are unique", + "data": [{"a": 1, "b": 2}, {"a": 2, "b": 1}], + "valid": true + }, + { + "description": "objects are non-unique despite key order", + "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}], + "valid": false } ] },