diff --git a/test-generator/prototype-safe.js b/test-generator/prototype-safe.js new file mode 100755 index 00000000..31e65738 --- /dev/null +++ b/test-generator/prototype-safe.js @@ -0,0 +1,173 @@ +#!/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)}' 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)}' as object", + "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(',') + },${ + ['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(',') + },${ + 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) diff --git a/tests/draft2019-09/prototype-safe.json b/tests/draft2019-09/prototype-safe.json new file mode 100644 index 00000000..7891f807 --- /dev/null +++ b/tests/draft2019-09/prototype-safe.json @@ -0,0 +1,624 @@ +[ + { + "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": "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' as number", + "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' as object", + "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' as number", + "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' as object", + "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__' as number", + "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__' as object", + "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 } + ] + } +] diff --git a/tests/draft4/prototype-safe.json b/tests/draft4/prototype-safe.json new file mode 100644 index 00000000..7891f807 --- /dev/null +++ b/tests/draft4/prototype-safe.json @@ -0,0 +1,624 @@ +[ + { + "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": "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' as number", + "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' as object", + "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' as number", + "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' as object", + "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__' as number", + "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__' as object", + "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 } + ] + } +] diff --git a/tests/draft6/prototype-safe.json b/tests/draft6/prototype-safe.json new file mode 100644 index 00000000..7891f807 --- /dev/null +++ b/tests/draft6/prototype-safe.json @@ -0,0 +1,624 @@ +[ + { + "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": "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' as number", + "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' as object", + "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' as number", + "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' as object", + "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__' as number", + "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__' as object", + "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 } + ] + } +] diff --git a/tests/draft7/prototype-safe.json b/tests/draft7/prototype-safe.json new file mode 100644 index 00000000..7891f807 --- /dev/null +++ b/tests/draft7/prototype-safe.json @@ -0,0 +1,624 @@ +[ + { + "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": "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' as number", + "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' as object", + "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' as number", + "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' as object", + "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__' as number", + "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__' as object", + "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 } + ] + } +]