236 lines
6.5 KiB
JSON
236 lines
6.5 KiB
JSON
[
|
|
{
|
|
"description": "required validation",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"properties": {
|
|
"foo": {},
|
|
"bar": {}
|
|
},
|
|
"required": [
|
|
"foo"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "present required property is valid",
|
|
"data": {
|
|
"foo": 1
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "non-present required property is invalid",
|
|
"data": {
|
|
"bar": 1
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "ignores arrays",
|
|
"data": [],
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores strings",
|
|
"data": "",
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores other non-objects",
|
|
"data": 12,
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores null",
|
|
"data": null,
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores boolean",
|
|
"data": true,
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "required default validation",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"properties": {
|
|
"foo": {}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "not required by default",
|
|
"data": {},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "required with empty array",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"properties": {
|
|
"foo": {}
|
|
},
|
|
"required": []
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "property not required",
|
|
"data": {},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "required with escaped characters",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"required": [
|
|
"foo\nbar",
|
|
"foo\"bar",
|
|
"foo\\bar",
|
|
"foo\rbar",
|
|
"foo\tbar",
|
|
"foo\fbar"
|
|
],
|
|
"extensible": true
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "object with all properties present 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 some properties missing is invalid",
|
|
"data": {
|
|
"foo\nbar": "1",
|
|
"foo\"bar": "1"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "required 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.",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"required": [
|
|
"__proto__",
|
|
"toString",
|
|
"constructor"
|
|
],
|
|
"extensible": true
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "ignores arrays",
|
|
"data": [],
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores other non-objects",
|
|
"data": 12,
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "none of the properties mentioned",
|
|
"data": {},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "__proto__ present",
|
|
"data": {
|
|
"__proto__": "foo"
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "toString present",
|
|
"data": {
|
|
"toString": {
|
|
"length": 37
|
|
}
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "constructor present",
|
|
"data": {
|
|
"constructor": {
|
|
"length": 37
|
|
}
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "all present",
|
|
"data": {
|
|
"__proto__": 12,
|
|
"toString": {
|
|
"length": "foo"
|
|
},
|
|
"constructor": 37
|
|
},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "extensible: true allows extra properties in required",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"required": [
|
|
"foo"
|
|
],
|
|
"extensible": true
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "extra property is valid",
|
|
"data": {
|
|
"foo": 1,
|
|
"bar": 2
|
|
},
|
|
"valid": true
|
|
}
|
|
]
|
|
}
|
|
] |