[ { "description": "properties with escaped characters", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { "foo\nbar": { "type": "number" }, "foo\"bar": { "type": "number" }, "foo\\bar": { "type": "number" }, "foo\rbar": { "type": "number" }, "foo\tbar": { "type": "number" }, "foo\fbar": { "type": "number" } } }, "tests": [ { "description": "object with all numbers is valid", "data": { "foo\nbar": 1, "foo\"bar": 1, "foo\\bar": 1, "foo\rbar": 1, "foo\tbar": 1, "foo\fbar": 1 }, "valid": true }, { "description": "object with strings is invalid", "data": { "foo\nbar": "1", "foo\"bar": "1", "foo\\bar": "1", "foo\rbar": "1", "foo\tbar": "1", "foo\fbar": "1" }, "valid": false } ] }, { "description": "properties with null valued instance properties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { "foo": { "type": "null" } } }, "tests": [ { "description": "allows null values", "data": { "foo": null }, "valid": true } ] }, { "description": "properties whose names are Javascript object property names", "comment": "Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object.", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { "__proto__": { "type": "number" }, "toString": { "properties": { "length": { "type": "string" } } }, "constructor": { "type": "number" } } }, "tests": [ { "description": "none of the properties mentioned", "data": {}, "valid": true }, { "description": "__proto__ not valid", "data": { "__proto__": "foo" }, "valid": false }, { "description": "toString not valid", "data": { "toString": { "length": 37 } }, "valid": false }, { "description": "constructor not valid", "data": { "constructor": { "length": 37 } }, "valid": false }, { "description": "all present and valid", "data": { "__proto__": 12, "toString": { "length": "foo" }, "constructor": 37 }, "valid": true } ] }, { "description": "property merging across multi-level inheritance", "enums": [], "puncs": [], "types": [ { "name": "properties_test.entity", "schemas": [ { "$id": "properties_test.entity", "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "type": { "type": "string", "const": "properties_test.entity" } }, "required": [ "id" ] } ] }, { "name": "properties_test.user", "schemas": [ { "$id": "properties_test.user", "$ref": "properties_test.entity", "properties": { "type": { "type": "string", "const": "properties_test.user", "override": true }, "password": { "type": "string", "minLength": 8 } }, "required": [ "password" ] } ] }, { "name": "properties_test.person", "schemas": [ { "$id": "properties_test.person", "$ref": "properties_test.user", "properties": { "type": { "type": "string", "const": "properties_test.person", "override": true }, "first_name": { "type": "string", "minLength": 1 }, "last_name": { "type": "string", "minLength": 1 } }, "required": [ "first_name", "last_name" ] } ] } ], "tests": [ { "description": "person inherits all properties correctly", "schema_id": "properties_test.person", "data": {}, "valid": true }, { "description": "validation keywords inherited and applied", "schema_id": "properties_test.person", "data": {}, "valid": false, "expect_errors": [ { "code": "MIN_LENGTH_VIOLATED", "path": "/password" }, { "code": "MIN_LENGTH_VIOLATED", "path": "/first_name" } ] } ] } ]