From 74709a8d3bc7afdaf946512af349c94ca9aa5220 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, 8 Jul 2020 19:12:39 +0300 Subject: [PATCH 1/4] Add basic tests for prototype safety Language-specific implementation details shouldn't affect property existence checks. Validators should not traverse JS prototype chain or assign to it. If a validator supports applying default values from the schema, it should pass with that both enabled or disabled. Testing that might detect significant issues in e.g. JS implementations. --- tests/draft2019-09/prototype-safe.json | 976 +++++++++++++++++++++++++ tests/draft4/prototype-safe.json | 976 +++++++++++++++++++++++++ tests/draft6/prototype-safe.json | 976 +++++++++++++++++++++++++ tests/draft7/prototype-safe.json | 976 +++++++++++++++++++++++++ 4 files changed, 3904 insertions(+) create mode 100644 tests/draft2019-09/prototype-safe.json create mode 100644 tests/draft4/prototype-safe.json create mode 100644 tests/draft6/prototype-safe.json create mode 100644 tests/draft7/prototype-safe.json diff --git a/tests/draft2019-09/prototype-safe.json b/tests/draft2019-09/prototype-safe.json new file mode 100644 index 00000000..f5b156c5 --- /dev/null +++ b/tests/draft2019-09/prototype-safe.json @@ -0,0 +1,976 @@ +[ + { + "description": "Does not see elements non existing on the object: 'x' as number", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "properties": { "x": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "x": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "x": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "x": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "x": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "x": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "x": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "x": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "x": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'x' as object", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "properties": { "x": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "x": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "x": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "x": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "x": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "x": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "x": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "x": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "x": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "x": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'x' via required", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "required": ["x"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "x": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "x": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "x": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "x": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "x": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "x": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "x": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "x": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "x": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "length": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "length": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "length": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "length": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "length": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["length"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "toString": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "toString": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "toString": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "toString": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "toString": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "toString": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "toString": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "toString": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "toString": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "toString": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "toString": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "toString": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "toString": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "toString": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "toString": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "toString": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "toString": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "toString": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "toString": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["toString"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "toString": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "toString": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "toString": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "toString": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "toString": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "toString": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "toString": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "toString": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "toString": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "constructor": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "constructor": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "constructor": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "constructor": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "constructor": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "constructor": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "constructor": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "constructor": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "constructor": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "constructor": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "constructor": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "constructor": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "constructor": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "constructor": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "constructor": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "constructor": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "constructor": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "constructor": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "constructor": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["constructor"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "constructor": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "constructor": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "constructor": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "constructor": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "constructor": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "constructor": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "constructor": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "constructor": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "constructor": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "__proto__": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__proto__": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "__proto__": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["__proto__"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__len": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__len": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__len": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__len": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__len": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__len": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__len": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__len"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__len": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__len": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__len": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__len": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__len": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__len": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__len": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__len": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__len": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__tostring": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__tostring": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__tostring": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__tostring": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__tostring": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__tostring": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__tostring": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__tostring"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__tostring": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__tostring": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__tostring": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__tostring": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__tostring": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__tostring": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__tostring": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__tostring": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__tostring": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__gc": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__gc": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__gc": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__gc": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__gc": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__gc": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__gc": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__gc"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__gc": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__gc": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__gc": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__gc": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__gc": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__gc": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__gc": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__gc": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__gc": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__index": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__index": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__index"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Default value: 'foo' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "foo": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: 'foo' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "foo": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["foo"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "foo": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "foo": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "foo": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "foo": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "foo": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "foo": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "foo": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "foo": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "foo": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "foo": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "foo": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "foo": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "foo": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "foo": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "foo": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "foo": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "foo": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "foo": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "foo": 42 }, "valid": false } + ] + }, + { + "description": "Default value: 'length' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "length": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: 'length' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "length": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["length"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "length": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "length": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "length": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "length": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "length": 42 }, "valid": false } + ] + }, + { + "description": "Default value: '__proto__' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: '__proto__' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "__proto__": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["__proto__"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__proto__": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__proto__": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__proto__": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } + ] + }, + { + "description": "Default value: '__index' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__index": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__index' property: '__index' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__index": { "properties": { "__index": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["__index"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__index": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__index": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } + ] + } +] diff --git a/tests/draft4/prototype-safe.json b/tests/draft4/prototype-safe.json new file mode 100644 index 00000000..f5b156c5 --- /dev/null +++ b/tests/draft4/prototype-safe.json @@ -0,0 +1,976 @@ +[ + { + "description": "Does not see elements non existing on the object: 'x' as number", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "properties": { "x": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "x": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "x": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "x": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "x": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "x": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "x": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "x": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "x": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'x' as object", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "properties": { "x": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "x": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "x": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "x": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "x": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "x": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "x": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "x": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "x": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "x": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'x' via required", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "required": ["x"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "x": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "x": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "x": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "x": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "x": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "x": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "x": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "x": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "x": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "length": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "length": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "length": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "length": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "length": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["length"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "toString": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "toString": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "toString": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "toString": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "toString": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "toString": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "toString": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "toString": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "toString": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "toString": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "toString": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "toString": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "toString": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "toString": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "toString": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "toString": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "toString": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "toString": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "toString": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["toString"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "toString": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "toString": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "toString": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "toString": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "toString": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "toString": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "toString": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "toString": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "toString": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "constructor": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "constructor": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "constructor": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "constructor": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "constructor": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "constructor": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "constructor": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "constructor": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "constructor": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "constructor": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "constructor": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "constructor": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "constructor": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "constructor": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "constructor": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "constructor": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "constructor": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "constructor": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "constructor": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["constructor"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "constructor": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "constructor": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "constructor": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "constructor": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "constructor": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "constructor": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "constructor": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "constructor": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "constructor": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "__proto__": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__proto__": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "__proto__": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["__proto__"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__len": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__len": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__len": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__len": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__len": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__len": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__len": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__len"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__len": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__len": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__len": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__len": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__len": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__len": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__len": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__len": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__len": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__tostring": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__tostring": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__tostring": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__tostring": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__tostring": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__tostring": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__tostring": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__tostring"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__tostring": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__tostring": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__tostring": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__tostring": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__tostring": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__tostring": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__tostring": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__tostring": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__tostring": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__gc": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__gc": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__gc": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__gc": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__gc": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__gc": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__gc": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__gc"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__gc": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__gc": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__gc": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__gc": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__gc": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__gc": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__gc": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__gc": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__gc": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__index": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__index": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__index"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Default value: 'foo' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "foo": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: 'foo' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "foo": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["foo"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "foo": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "foo": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "foo": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "foo": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "foo": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "foo": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "foo": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "foo": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "foo": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "foo": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "foo": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "foo": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "foo": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "foo": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "foo": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "foo": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "foo": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "foo": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "foo": 42 }, "valid": false } + ] + }, + { + "description": "Default value: 'length' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "length": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: 'length' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "length": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["length"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "length": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "length": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "length": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "length": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "length": 42 }, "valid": false } + ] + }, + { + "description": "Default value: '__proto__' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: '__proto__' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "__proto__": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["__proto__"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__proto__": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__proto__": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__proto__": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } + ] + }, + { + "description": "Default value: '__index' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__index": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__index' property: '__index' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__index": { "properties": { "__index": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["__index"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__index": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__index": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } + ] + } +] diff --git a/tests/draft6/prototype-safe.json b/tests/draft6/prototype-safe.json new file mode 100644 index 00000000..f5b156c5 --- /dev/null +++ b/tests/draft6/prototype-safe.json @@ -0,0 +1,976 @@ +[ + { + "description": "Does not see elements non existing on the object: 'x' as number", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "properties": { "x": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "x": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "x": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "x": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "x": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "x": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "x": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "x": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "x": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'x' as object", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "properties": { "x": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "x": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "x": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "x": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "x": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "x": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "x": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "x": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "x": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "x": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'x' via required", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "required": ["x"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "x": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "x": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "x": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "x": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "x": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "x": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "x": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "x": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "x": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "length": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "length": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "length": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "length": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "length": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["length"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "toString": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "toString": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "toString": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "toString": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "toString": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "toString": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "toString": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "toString": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "toString": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "toString": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "toString": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "toString": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "toString": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "toString": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "toString": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "toString": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "toString": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "toString": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "toString": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["toString"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "toString": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "toString": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "toString": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "toString": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "toString": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "toString": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "toString": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "toString": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "toString": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "constructor": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "constructor": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "constructor": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "constructor": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "constructor": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "constructor": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "constructor": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "constructor": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "constructor": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "constructor": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "constructor": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "constructor": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "constructor": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "constructor": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "constructor": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "constructor": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "constructor": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "constructor": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "constructor": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["constructor"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "constructor": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "constructor": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "constructor": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "constructor": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "constructor": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "constructor": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "constructor": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "constructor": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "constructor": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "__proto__": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__proto__": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "__proto__": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["__proto__"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__len": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__len": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__len": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__len": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__len": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__len": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__len": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__len"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__len": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__len": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__len": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__len": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__len": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__len": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__len": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__len": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__len": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__tostring": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__tostring": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__tostring": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__tostring": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__tostring": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__tostring": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__tostring": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__tostring"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__tostring": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__tostring": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__tostring": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__tostring": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__tostring": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__tostring": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__tostring": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__tostring": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__tostring": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__gc": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__gc": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__gc": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__gc": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__gc": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__gc": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__gc": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__gc"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__gc": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__gc": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__gc": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__gc": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__gc": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__gc": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__gc": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__gc": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__gc": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__index": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__index": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__index"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Default value: 'foo' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "foo": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: 'foo' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "foo": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["foo"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "foo": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "foo": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "foo": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "foo": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "foo": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "foo": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "foo": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "foo": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "foo": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "foo": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "foo": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "foo": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "foo": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "foo": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "foo": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "foo": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "foo": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "foo": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "foo": 42 }, "valid": false } + ] + }, + { + "description": "Default value: 'length' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "length": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: 'length' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "length": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["length"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "length": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "length": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "length": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "length": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "length": 42 }, "valid": false } + ] + }, + { + "description": "Default value: '__proto__' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: '__proto__' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "__proto__": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["__proto__"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__proto__": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__proto__": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__proto__": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } + ] + }, + { + "description": "Default value: '__index' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__index": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__index' property: '__index' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__index": { "properties": { "__index": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["__index"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__index": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__index": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } + ] + } +] diff --git a/tests/draft7/prototype-safe.json b/tests/draft7/prototype-safe.json new file mode 100644 index 00000000..f5b156c5 --- /dev/null +++ b/tests/draft7/prototype-safe.json @@ -0,0 +1,976 @@ +[ + { + "description": "Does not see elements non existing on the object: 'x' as number", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "properties": { "x": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "x": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "x": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "x": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "x": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "x": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "x": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "x": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "x": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'x' as object", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "properties": { "x": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "x": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "x": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "x": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "x": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "x": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "x": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "x": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "x": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "x": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'x' via required", + "comment": "This is a baseline check to validate that other properties are treated the same and are not special compared to it", + "schema": { + "required": ["x"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "x": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "x": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "x": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "x": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "x": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "x": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "x": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "x": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "x": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "length": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "length": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "length": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "length": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "length": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'length' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["length"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "toString": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "toString": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "toString": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "toString": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "toString": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "toString": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "toString": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "toString": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "toString": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "toString": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "toString": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "toString": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "toString": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "toString": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "toString": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "toString": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "toString": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "toString": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "toString": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'toString' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["toString"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "toString": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "toString": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "toString": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "toString": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "toString": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "toString": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "toString": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "toString": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "toString": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "constructor": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "constructor": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "constructor": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "constructor": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "constructor": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "constructor": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "constructor": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "constructor": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "constructor": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "constructor": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "constructor": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "constructor": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "constructor": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "constructor": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "constructor": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "constructor": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "constructor": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "constructor": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "constructor": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: 'constructor' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["constructor"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "constructor": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "constructor": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "constructor": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "constructor": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "constructor": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "constructor": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "constructor": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "constructor": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "constructor": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' as number", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "__proto__": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__proto__": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' as object", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "properties": { "__proto__": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__proto__' via required", + "comment": "This is a common bug of some of the JS validators, this test detects it", + "schema": { + "required": ["__proto__"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__len": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__len": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__len": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__len": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__len": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__len": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__len": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__len' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__len"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__len": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__len": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__len": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__len": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__len": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__len": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__len": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__len": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__len": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__tostring": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__tostring": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__tostring": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__tostring": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__tostring": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__tostring": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__tostring": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__tostring' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__tostring"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__tostring": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__tostring": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__tostring": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__tostring": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__tostring": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__tostring": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__tostring": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__tostring": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__tostring": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__gc": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__gc": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__gc": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__gc": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__gc": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__gc": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__gc": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__gc' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__gc"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__gc": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__gc": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__gc": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__gc": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__gc": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__gc": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__gc": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__gc": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__gc": 42 }, "valid": true } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' as number", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__index": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' as object", + "comment": "Also test for Lua special name handling", + "schema": { + "properties": { "__index": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } + ] + }, + { + "description": "Does not see elements non existing on the object: '__index' via required", + "comment": "Also test for Lua special name handling", + "schema": { + "required": ["__index"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Default value: 'foo' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "foo": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: 'foo' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "foo": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["foo"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "foo": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "foo": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "foo": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "foo": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "foo": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "foo": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "foo": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "foo": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "foo": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "foo": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "foo": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "foo": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "foo": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "foo": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "foo": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "foo": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "foo": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "foo": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'foo' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "foo": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "foo": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "foo": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "foo": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "foo": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "foo": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "foo": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "foo": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "foo": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "foo": 42 }, "valid": false } + ] + }, + { + "description": "Default value: 'length' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "length": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: 'length' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "length": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["length"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "length": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "length": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "length": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "length": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "length": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "length": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "length": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "length": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "length": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "length": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "length": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: 'length' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "length": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "length": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "length": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "length": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "length": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "length": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "length": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "length": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "length": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "length": 42 }, "valid": false } + ] + }, + { + "description": "Default value: '__proto__' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__proto__' property: '__proto__' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__proto__": { "properties": { "__proto__": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["__proto__"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__proto__": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__proto__": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__proto__": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__proto__": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__proto__": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__proto__": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__proto__": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__proto__": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__proto__": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__proto__": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__proto__": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__proto__": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__proto__": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__proto__": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__proto__": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__proto__": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__proto__": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__proto__": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } + ] + }, + { + "description": "Default value: '__index' as number", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__index": { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Default value on a '__index' property: '__index' as object", + "comment": "Default should not affect passing validation in all cases", + "schema": { + "properties": { "__index": { "properties": { "__index": { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "required": ["__index"] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, + { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__index": { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } + ] + }, + { + "description": "Does not see inexisting elements on new objects: '__index' via required", + "comment": "Validating a new object should not be affected by previous default", + "schema": { + "properties": { "__index": { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } + ] + } +] From eae4651ac82cce757c6498d627ad1d0435f07f2a 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, 8 Jul 2020 19:42:21 +0300 Subject: [PATCH 2/4] Add a generator for prototype-safe.json file --- test-generator/prototype-safe.js | 170 +++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100755 test-generator/prototype-safe.js diff --git a/test-generator/prototype-safe.js b/test-generator/prototype-safe.js new file mode 100755 index 00000000..9831c19d --- /dev/null +++ b/test-generator/prototype-safe.js @@ -0,0 +1,170 @@ +#!/usr/bin/env node + +'use strict' + +const string = name => JSON.stringify(name) +const inline = name => JSON.stringify(name).slice(1, -1) + +const makeNumber = name => ` + "schema": { + "properties": { ${string(name)}: { "type": "number" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { ${string(name)}: 10 }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { ${string(name)}: "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { ${string(name)}: "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { ${string(name)}: true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { ${string(name)}: false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { ${string(name)}: [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { ${string(name)}: [] }, "valid": false }, + { "description": "Invalid if incorrect (object)", "data": { ${string(name)}: {} }, "valid": false } + ]`.trim() +const makeObject = name => ` + "schema": { + "properties": { ${string(name)}: { "type": "object" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if correct", "data": { ${string(name)}: {} }, "valid": true }, + { "description": "Invalid if incorrect (string)", "data": { ${string(name)}: "foo" }, "valid": false }, + { "description": "Invalid if incorrect (empty string)", "data": { ${string(name)}: "" }, "valid": false }, + { "description": "Invalid if incorrect (boolean true)", "data": { ${string(name)}: true }, "valid": false }, + { "description": "Invalid if incorrect (boolean false)", "data": { ${string(name)}: false }, "valid": false }, + { "description": "Invalid if incorrect (array)", "data": { ${string(name)}: [42] }, "valid": false }, + { "description": "Invalid if incorrect (empty array)", "data": { ${string(name)}: [] }, "valid": false }, + { "description": "Invalid if incorrect (zero number)", "data": { ${string(name)}: 0 }, "valid": false }, + { "description": "Invalid if incorrect (number)", "data": { ${string(name)}: 42 }, "valid": false } + ]`.trim() +const makeRequired = name => ` + "schema": { + "required": [${string(name)}] + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Invalid if not present", "data": {}, "valid": false }, + { "description": "Valid if present (string)", "data": { ${string(name)}: "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { ${string(name)}: "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { ${string(name)}: true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { ${string(name)}: false }, "valid": true }, + { "description": "Valid if present (array)", "data": { ${string(name)}: [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { ${string(name)}: [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { ${string(name)}: {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { ${string(name)}: 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { ${string(name)}: 42 }, "valid": true } + ]`.trim() +const makeDefault = name => ` + "schema": { + "properties": { ${string(name)}: { "default": "foo" } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { ${string(name)}: "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { ${string(name)}: "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { ${string(name)}: true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { ${string(name)}: false }, "valid": true }, + { "description": "Valid if present (array)", "data": { ${string(name)}: [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { ${string(name)}: [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { ${string(name)}: {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { ${string(name)}: 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { ${string(name)}: 42 }, "valid": true } + ]`.trim() +const makePropertyDefault = (name, parent) => ` + "schema": { + "properties": { ${string(parent)}: { "properties": { ${string(name)}: { "default": "foo" } } } } + }, + "tests": [ + { "description": "Valid on numbers", "data": 0, "valid": true }, + { "description": "Valid on arrays", "data": [], "valid": true }, + { "description": "Valid if not present", "data": {}, "valid": true }, + { "description": "Valid if present (string)", "data": { ${string(name)}: "foo" }, "valid": true }, + { "description": "Valid if present (empty string)", "data": { ${string(name)}: "" }, "valid": true }, + { "description": "Valid if present (boolean true)", "data": { ${string(name)}: true }, "valid": true }, + { "description": "Valid if present (boolean false)", "data": { ${string(name)}: false }, "valid": true }, + { "description": "Valid if present (array)", "data": { ${string(name)}: [42] }, "valid": true }, + { "description": "Valid if present (empty array)", "data": { ${string(name)}: [] }, "valid": true }, + { "description": "Valid if present (object)", "data": { ${string(name)}: {} }, "valid": true }, + { "description": "Valid if present (zero number)", "data": { ${string(name)}: 0 }, "valid": true }, + { "description": "Valid if present (number)", "data": { ${string(name)}: 42 }, "valid": true } + ]`.trim() +const makeBlock = (name, comment) => ` + { + "description": "Does not see elements non existing on the object: '${inline(name)}' as number", + "comment": ${string(comment)}, + ${makeNumber(name)} + }, + { + "description": "Does not see elements non existing on the object: '${inline(name)}' as object", + "comment": ${string(comment)}, + ${makeObject(name)} + }, + { + "description": "Does not see elements non existing on the object: '${inline(name)}' via required", + "comment": ${string(comment)}, + ${makeRequired(name)} + }` +const makeBlockDefault = (name, proto) => ` + { + "description": "Default value: '${inline(name)}' as number", + "comment": "Default should not affect passing validation in all cases", + ${makeDefault(name)} + }, + { + "description": "Default value on a '${string(proto).slice(1, -1)}' property: '${inline(name)}' as object", + "comment": "Default should not affect passing validation in all cases", + ${makePropertyDefault(name, proto)} + }, + { + "description": "Does not see inexisting elements on new objects: '${inline(name)}' via required", + "comment": "Validating a new object should not be affected by previous default", + ${makeRequired(name)} + }, + { + "description": "Does not see inexisting elements on new objects: '${inline(name)}' via required", + "comment": "Validating a new object should not be affected by previous default", + ${makeNumber(name)} + }, + { + "description": "Does not see inexisting elements on new objects: '${inline(name)}' via required", + "comment": "Validating a new object should not be affected by previous default", + ${makeObject(name)} + }` +const tests = `[${ + makeBlock('x', 'This is a baseline check to validate that other properties are treated the same and are not special compared to it') + },${ + ['length', 'toString', 'constructor', '__proto__'].map(name => + makeBlock(name, 'This is a common bug of some of the JS validators, this test detects it') + ).join(',') + },${ + ['__len', '__tostring', '__gc', '__index'].map(name => + makeBlock(name, 'Also test for Lua special name handling') + ).join(',') + },${ + ['foo', 'length', '__proto__'].map(name => makeBlockDefault(name, '__proto__')).join(',') + },${ + makeBlockDefault('__index', '__index') + } +]` + +// Ensure that everything is correct by checking against the validator +/* +const schemasafe = require('@exodus/schemasafe') +for (const useDefaults of [false, true]) { + for (const suite of JSON.parse(tests)) { + const validate = schemasafe.validator(suite.schema, { useDefaults }) + for (const test of suite.tests) { + if (validate(test.data) !== test.valid) + throw new Error(`${suite.description} / ${test.description}: expected ${test.valid} (defaults: ${useDefaults})`) + } + } +} +*/ + +console.log(tests) From ad19e2c9ee11af44a76e981c944fd3433c9e4aec 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: Tue, 14 Jul 2020 08:15:08 +0300 Subject: [PATCH 3/4] Remove Lua-targeting tests for now Until they are checked against any actual Lua impl and it's confirmed that they are useful. --- test-generator/prototype-safe.js | 7 +- tests/draft2019-09/prototype-safe.json | 352 ------------------------- tests/draft4/prototype-safe.json | 352 ------------------------- tests/draft6/prototype-safe.json | 352 ------------------------- tests/draft7/prototype-safe.json | 352 ------------------------- 5 files changed, 5 insertions(+), 1410 deletions(-) diff --git a/test-generator/prototype-safe.js b/test-generator/prototype-safe.js index 9831c19d..8f6b4807 100755 --- a/test-generator/prototype-safe.js +++ b/test-generator/prototype-safe.js @@ -142,14 +142,17 @@ const tests = `[${ ['length', 'toString', 'constructor', '__proto__'].map(name => makeBlock(name, 'This is a common bug of some of the JS validators, this test detects it') ).join(',') + },${ + ['foo', 'length', '__proto__'].map(name => makeBlockDefault(name, '__proto__')).join(',') + /* + // Lua-targeting, commented out until tested against an actual Lua-based impl },${ ['__len', '__tostring', '__gc', '__index'].map(name => makeBlock(name, 'Also test for Lua special name handling') ).join(',') - },${ - ['foo', 'length', '__proto__'].map(name => makeBlockDefault(name, '__proto__')).join(',') },${ makeBlockDefault('__index', '__index') + */ } ]` diff --git a/tests/draft2019-09/prototype-safe.json b/tests/draft2019-09/prototype-safe.json index f5b156c5..1f0379ce 100644 --- a/tests/draft2019-09/prototype-safe.json +++ b/tests/draft2019-09/prototype-safe.json @@ -309,254 +309,6 @@ { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } ] }, - { - "description": "Does not see elements non existing on the object: '__len' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__len": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__len": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__len": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__len' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__len": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__len": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__len": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__len": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__len' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__len"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__len": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__len": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__len": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__len": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__len": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__len": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__len": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__len": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__len": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__tostring": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__tostring": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__tostring": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__tostring": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__tostring": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__tostring": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__tostring": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__tostring"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__tostring": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__tostring": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__tostring": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__tostring": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__tostring": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__tostring": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__tostring": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__tostring": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__tostring": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__gc": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__gc": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__gc": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__gc": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__gc": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__gc": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__gc": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__gc"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__gc": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__gc": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__gc": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__gc": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__gc": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__gc": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__gc": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__gc": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__gc": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__index": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__index": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__index"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, { "description": "Default value: 'foo' as number", "comment": "Default should not affect passing validation in all cases", @@ -868,109 +620,5 @@ { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } ] - }, - { - "description": "Default value: '__index' as number", - "comment": "Default should not affect passing validation in all cases", - "schema": { - "properties": { "__index": { "default": "foo" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Default value on a '__index' property: '__index' as object", - "comment": "Default should not affect passing validation in all cases", - "schema": { - "properties": { "__index": { "properties": { "__index": { "default": "foo" } } } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "required": ["__index"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "properties": { "__index": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "properties": { "__index": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } - ] } ] diff --git a/tests/draft4/prototype-safe.json b/tests/draft4/prototype-safe.json index f5b156c5..1f0379ce 100644 --- a/tests/draft4/prototype-safe.json +++ b/tests/draft4/prototype-safe.json @@ -309,254 +309,6 @@ { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } ] }, - { - "description": "Does not see elements non existing on the object: '__len' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__len": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__len": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__len": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__len' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__len": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__len": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__len": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__len": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__len' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__len"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__len": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__len": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__len": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__len": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__len": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__len": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__len": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__len": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__len": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__tostring": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__tostring": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__tostring": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__tostring": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__tostring": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__tostring": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__tostring": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__tostring"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__tostring": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__tostring": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__tostring": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__tostring": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__tostring": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__tostring": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__tostring": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__tostring": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__tostring": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__gc": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__gc": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__gc": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__gc": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__gc": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__gc": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__gc": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__gc"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__gc": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__gc": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__gc": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__gc": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__gc": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__gc": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__gc": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__gc": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__gc": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__index": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__index": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__index"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, { "description": "Default value: 'foo' as number", "comment": "Default should not affect passing validation in all cases", @@ -868,109 +620,5 @@ { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } ] - }, - { - "description": "Default value: '__index' as number", - "comment": "Default should not affect passing validation in all cases", - "schema": { - "properties": { "__index": { "default": "foo" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Default value on a '__index' property: '__index' as object", - "comment": "Default should not affect passing validation in all cases", - "schema": { - "properties": { "__index": { "properties": { "__index": { "default": "foo" } } } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "required": ["__index"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "properties": { "__index": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "properties": { "__index": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } - ] } ] diff --git a/tests/draft6/prototype-safe.json b/tests/draft6/prototype-safe.json index f5b156c5..1f0379ce 100644 --- a/tests/draft6/prototype-safe.json +++ b/tests/draft6/prototype-safe.json @@ -309,254 +309,6 @@ { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } ] }, - { - "description": "Does not see elements non existing on the object: '__len' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__len": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__len": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__len": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__len' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__len": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__len": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__len": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__len": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__len' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__len"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__len": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__len": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__len": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__len": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__len": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__len": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__len": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__len": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__len": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__tostring": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__tostring": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__tostring": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__tostring": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__tostring": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__tostring": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__tostring": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__tostring"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__tostring": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__tostring": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__tostring": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__tostring": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__tostring": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__tostring": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__tostring": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__tostring": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__tostring": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__gc": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__gc": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__gc": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__gc": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__gc": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__gc": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__gc": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__gc"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__gc": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__gc": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__gc": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__gc": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__gc": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__gc": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__gc": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__gc": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__gc": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__index": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__index": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__index"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, { "description": "Default value: 'foo' as number", "comment": "Default should not affect passing validation in all cases", @@ -868,109 +620,5 @@ { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } ] - }, - { - "description": "Default value: '__index' as number", - "comment": "Default should not affect passing validation in all cases", - "schema": { - "properties": { "__index": { "default": "foo" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Default value on a '__index' property: '__index' as object", - "comment": "Default should not affect passing validation in all cases", - "schema": { - "properties": { "__index": { "properties": { "__index": { "default": "foo" } } } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "required": ["__index"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "properties": { "__index": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "properties": { "__index": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } - ] } ] diff --git a/tests/draft7/prototype-safe.json b/tests/draft7/prototype-safe.json index f5b156c5..1f0379ce 100644 --- a/tests/draft7/prototype-safe.json +++ b/tests/draft7/prototype-safe.json @@ -309,254 +309,6 @@ { "description": "Valid if present (number)", "data": { "__proto__": 42 }, "valid": true } ] }, - { - "description": "Does not see elements non existing on the object: '__len' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__len": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__len": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__len": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__len' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__len": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__len": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__len": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__len": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__len": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__len": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__len": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__len": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__len": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__len": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__len' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__len"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__len": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__len": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__len": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__len": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__len": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__len": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__len": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__len": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__len": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__tostring": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__tostring": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__tostring": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__tostring": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__tostring": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__tostring": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__tostring": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__tostring": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__tostring": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__tostring": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__tostring": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__tostring": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__tostring": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__tostring' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__tostring"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__tostring": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__tostring": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__tostring": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__tostring": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__tostring": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__tostring": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__tostring": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__tostring": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__tostring": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__gc": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__gc": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__gc": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__gc": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__gc": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__gc": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__gc": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__gc": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__gc": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__gc": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__gc": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__gc": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__gc": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__gc' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__gc"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__gc": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__gc": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__gc": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__gc": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__gc": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__gc": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__gc": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__gc": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__gc": 42 }, "valid": true } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' as number", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__index": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' as object", - "comment": "Also test for Lua special name handling", - "schema": { - "properties": { "__index": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } - ] - }, - { - "description": "Does not see elements non existing on the object: '__index' via required", - "comment": "Also test for Lua special name handling", - "schema": { - "required": ["__index"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, { "description": "Default value: 'foo' as number", "comment": "Default should not affect passing validation in all cases", @@ -868,109 +620,5 @@ { "description": "Invalid if incorrect (zero number)", "data": { "__proto__": 0 }, "valid": false }, { "description": "Invalid if incorrect (number)", "data": { "__proto__": 42 }, "valid": false } ] - }, - { - "description": "Default value: '__index' as number", - "comment": "Default should not affect passing validation in all cases", - "schema": { - "properties": { "__index": { "default": "foo" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Default value on a '__index' property: '__index' as object", - "comment": "Default should not affect passing validation in all cases", - "schema": { - "properties": { "__index": { "properties": { "__index": { "default": "foo" } } } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "required": ["__index"] - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Invalid if not present", "data": {}, "valid": false }, - { "description": "Valid if present (string)", "data": { "__index": "foo" }, "valid": true }, - { "description": "Valid if present (empty string)", "data": { "__index": "" }, "valid": true }, - { "description": "Valid if present (boolean true)", "data": { "__index": true }, "valid": true }, - { "description": "Valid if present (boolean false)", "data": { "__index": false }, "valid": true }, - { "description": "Valid if present (array)", "data": { "__index": [42] }, "valid": true }, - { "description": "Valid if present (empty array)", "data": { "__index": [] }, "valid": true }, - { "description": "Valid if present (object)", "data": { "__index": {} }, "valid": true }, - { "description": "Valid if present (zero number)", "data": { "__index": 0 }, "valid": true }, - { "description": "Valid if present (number)", "data": { "__index": 42 }, "valid": true } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "properties": { "__index": { "type": "number" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": 10 }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (object)", "data": { "__index": {} }, "valid": false } - ] - }, - { - "description": "Does not see inexisting elements on new objects: '__index' via required", - "comment": "Validating a new object should not be affected by previous default", - "schema": { - "properties": { "__index": { "type": "object" } } - }, - "tests": [ - { "description": "Valid on numbers", "data": 0, "valid": true }, - { "description": "Valid on arrays", "data": [], "valid": true }, - { "description": "Valid if not present", "data": {}, "valid": true }, - { "description": "Valid if correct", "data": { "__index": {} }, "valid": true }, - { "description": "Invalid if incorrect (string)", "data": { "__index": "foo" }, "valid": false }, - { "description": "Invalid if incorrect (empty string)", "data": { "__index": "" }, "valid": false }, - { "description": "Invalid if incorrect (boolean true)", "data": { "__index": true }, "valid": false }, - { "description": "Invalid if incorrect (boolean false)", "data": { "__index": false }, "valid": false }, - { "description": "Invalid if incorrect (array)", "data": { "__index": [42] }, "valid": false }, - { "description": "Invalid if incorrect (empty array)", "data": { "__index": [] }, "valid": false }, - { "description": "Invalid if incorrect (zero number)", "data": { "__index": 0 }, "valid": false }, - { "description": "Invalid if incorrect (number)", "data": { "__index": 42 }, "valid": false } - ] } ] From cf26b9f1bc4b748a06c9278755719e8a7049bcd6 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, 15 Jul 2020 10:16:16 +0300 Subject: [PATCH 4/4] Fix descriptions in makeBlockDefault --- test-generator/prototype-safe.js | 4 ++-- tests/draft2019-09/prototype-safe.json | 12 ++++++------ tests/draft4/prototype-safe.json | 12 ++++++------ tests/draft6/prototype-safe.json | 12 ++++++------ tests/draft7/prototype-safe.json | 12 ++++++------ 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/test-generator/prototype-safe.js b/test-generator/prototype-safe.js index 8f6b4807..31e65738 100755 --- a/test-generator/prototype-safe.js +++ b/test-generator/prototype-safe.js @@ -127,12 +127,12 @@ const makeBlockDefault = (name, proto) => ` ${makeRequired(name)} }, { - "description": "Does not see inexisting elements on new objects: '${inline(name)}' via required", + "description": "Does not see inexisting elements on new objects: '${inline(name)}' as number", "comment": "Validating a new object should not be affected by previous default", ${makeNumber(name)} }, { - "description": "Does not see inexisting elements on new objects: '${inline(name)}' via required", + "description": "Does not see inexisting elements on new objects: '${inline(name)}' as object", "comment": "Validating a new object should not be affected by previous default", ${makeObject(name)} }` diff --git a/tests/draft2019-09/prototype-safe.json b/tests/draft2019-09/prototype-safe.json index 1f0379ce..7891f807 100644 --- a/tests/draft2019-09/prototype-safe.json +++ b/tests/draft2019-09/prototype-safe.json @@ -373,7 +373,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'foo' via required", + "description": "Does not see inexisting elements on new objects: 'foo' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "foo": { "type": "number" } } @@ -393,7 +393,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'foo' via required", + "description": "Does not see inexisting elements on new objects: 'foo' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "foo": { "type": "object" } } @@ -477,7 +477,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'length' via required", + "description": "Does not see inexisting elements on new objects: 'length' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "length": { "type": "number" } } @@ -497,7 +497,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'length' via required", + "description": "Does not see inexisting elements on new objects: 'length' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "length": { "type": "object" } } @@ -581,7 +581,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "description": "Does not see inexisting elements on new objects: '__proto__' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "__proto__": { "type": "number" } } @@ -601,7 +601,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "description": "Does not see inexisting elements on new objects: '__proto__' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "__proto__": { "type": "object" } } diff --git a/tests/draft4/prototype-safe.json b/tests/draft4/prototype-safe.json index 1f0379ce..7891f807 100644 --- a/tests/draft4/prototype-safe.json +++ b/tests/draft4/prototype-safe.json @@ -373,7 +373,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'foo' via required", + "description": "Does not see inexisting elements on new objects: 'foo' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "foo": { "type": "number" } } @@ -393,7 +393,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'foo' via required", + "description": "Does not see inexisting elements on new objects: 'foo' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "foo": { "type": "object" } } @@ -477,7 +477,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'length' via required", + "description": "Does not see inexisting elements on new objects: 'length' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "length": { "type": "number" } } @@ -497,7 +497,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'length' via required", + "description": "Does not see inexisting elements on new objects: 'length' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "length": { "type": "object" } } @@ -581,7 +581,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "description": "Does not see inexisting elements on new objects: '__proto__' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "__proto__": { "type": "number" } } @@ -601,7 +601,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "description": "Does not see inexisting elements on new objects: '__proto__' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "__proto__": { "type": "object" } } diff --git a/tests/draft6/prototype-safe.json b/tests/draft6/prototype-safe.json index 1f0379ce..7891f807 100644 --- a/tests/draft6/prototype-safe.json +++ b/tests/draft6/prototype-safe.json @@ -373,7 +373,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'foo' via required", + "description": "Does not see inexisting elements on new objects: 'foo' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "foo": { "type": "number" } } @@ -393,7 +393,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'foo' via required", + "description": "Does not see inexisting elements on new objects: 'foo' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "foo": { "type": "object" } } @@ -477,7 +477,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'length' via required", + "description": "Does not see inexisting elements on new objects: 'length' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "length": { "type": "number" } } @@ -497,7 +497,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'length' via required", + "description": "Does not see inexisting elements on new objects: 'length' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "length": { "type": "object" } } @@ -581,7 +581,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "description": "Does not see inexisting elements on new objects: '__proto__' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "__proto__": { "type": "number" } } @@ -601,7 +601,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "description": "Does not see inexisting elements on new objects: '__proto__' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "__proto__": { "type": "object" } } diff --git a/tests/draft7/prototype-safe.json b/tests/draft7/prototype-safe.json index 1f0379ce..7891f807 100644 --- a/tests/draft7/prototype-safe.json +++ b/tests/draft7/prototype-safe.json @@ -373,7 +373,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'foo' via required", + "description": "Does not see inexisting elements on new objects: 'foo' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "foo": { "type": "number" } } @@ -393,7 +393,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'foo' via required", + "description": "Does not see inexisting elements on new objects: 'foo' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "foo": { "type": "object" } } @@ -477,7 +477,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'length' via required", + "description": "Does not see inexisting elements on new objects: 'length' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "length": { "type": "number" } } @@ -497,7 +497,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: 'length' via required", + "description": "Does not see inexisting elements on new objects: 'length' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "length": { "type": "object" } } @@ -581,7 +581,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "description": "Does not see inexisting elements on new objects: '__proto__' as number", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "__proto__": { "type": "number" } } @@ -601,7 +601,7 @@ ] }, { - "description": "Does not see inexisting elements on new objects: '__proto__' via required", + "description": "Does not see inexisting elements on new objects: '__proto__' as object", "comment": "Validating a new object should not be affected by previous default", "schema": { "properties": { "__proto__": { "type": "object" } }