boon now included

This commit is contained in:
2025-09-30 01:10:58 -04:00
parent c9b1245a57
commit cc04f38c14
77 changed files with 12905 additions and 52 deletions

View File

@ -0,0 +1,21 @@
[
{
"description": "zero fraction",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": 2
},
"tests": [
{
"description": "with fraction",
"data": 2.0,
"valid": true
},
{
"description": "without fraction",
"data": 2,
"valid": true
}
]
}
]

View File

@ -0,0 +1,26 @@
[
{
"description": "guard against infinite recursion",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"alice": {
"$anchor": "alice",
"allOf": [{"$ref": "#bob"}]
},
"bob": {
"$anchor": "bob",
"allOf": [{"$ref": "#alice"}]
}
},
"$ref": "#alice"
},
"tests": [
{
"description": "infinite recursion detected",
"data": {},
"valid": false
}
]
}
]

View File

@ -0,0 +1,143 @@
[
{
"description": "validation of binary-encoded media type documents with schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json",
"contentEncoding": "base64",
"contentSchema": { "required": ["foo"], "properties": { "foo": { "type": "string" } } }
},
"tests": [
{
"description": "a valid base64-encoded JSON document",
"data": "eyJmb28iOiAiYmFyIn0K",
"valid": true
},
{
"description": "another valid base64-encoded JSON document",
"data": "eyJib28iOiAyMCwgImZvbyI6ICJiYXoifQ==",
"valid": true
},
{
"description": "an invalid base64-encoded JSON document; validates false",
"data": "eyJib28iOiAyMH0=",
"valid": false
},
{
"description": "an empty object as a base64-encoded JSON document; validates false",
"data": "e30=",
"valid": false
},
{
"description": "an empty array as a base64-encoded JSON document",
"data": "W10=",
"valid": true
},
{
"description": "a validly-encoded invalid JSON document; validates false",
"data": "ezp9Cg==",
"valid": false
},
{
"description": "an invalid base64 string that is valid JSON; validates false",
"data": "{}",
"valid": false
},
{
"description": "ignores non-strings",
"data": 100,
"valid": true
}
]
},
{
"description": "contentSchema without contentMediaType",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentEncoding": "base64",
"contentSchema": { "required": ["foo"], "properties": { "foo": { "type": "string" } } }
},
"tests": [
{
"description": "a valid base64-encoded JSON document",
"data": "eyJmb28iOiAiYmFyIn0K",
"valid": true
},
{
"description": "another valid base64-encoded JSON document",
"data": "eyJib28iOiAyMCwgImZvbyI6ICJiYXoifQ==",
"valid": true
},
{
"description": "an invalid base64-encoded JSON document; validates true",
"data": "eyJib28iOiAyMH0=",
"valid": true
},
{
"description": "an empty object as a base64-encoded JSON document; validates true",
"data": "e30=",
"valid": true
},
{
"description": "an empty array as a base64-encoded JSON document",
"data": "W10=",
"valid": true
},
{
"description": "a validly-encoded invalid JSON document; validates true",
"data": "ezp9Cg==",
"valid": true
},
{
"description": "an invalid base64 string that is valid JSON; validates false",
"data": "{}",
"valid": false
},
{
"description": "ignores non-strings",
"data": 100,
"valid": true
}
]
},
{
"description": "contentSchema without contentEncoding",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json",
"contentSchema": { "required": ["foo"], "properties": { "foo": { "type": "string" } } }
},
"tests": [
{
"description": "a valid JSON document",
"data": "{\"foo\": \"bar\"}",
"valid": true
},
{
"description": "another valid base64-encoded JSON document",
"data": "{\"boo\": 20, \"foo\": \"baz\"}",
"valid": true
},
{
"description": "an empty object; validates false",
"data": "{}",
"valid": false
},
{
"description": "an empty array; validates false",
"data": "[]",
"valid": true
},
{
"description": "invalid JSON document; validates false",
"data": "[}",
"valid": false
},
{
"description": "ignores non-strings",
"data": 100,
"valid": true
}
]
}
]

View File

@ -0,0 +1,16 @@
[
{
"description": "validation of date strings",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"format": "date"
},
"tests": [
{
"description": "contains alphabets",
"data": "yyyy-mm-dd",
"valid": false
}
]
}
]

View File

@ -0,0 +1,16 @@
[
{
"description": "validation of duration strings",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"format": "duration"
},
"tests": [
{
"description": "more than one T",
"data": "PT1MT1S",
"valid": false
}
]
}
]

View File

@ -0,0 +1,31 @@
[
{
"description": "validation of duration strings",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"format": "email"
},
"tests": [
{
"description": "non printable character",
"data": "a\tb@gmail.com",
"valid": false
},
{
"description": "tab ok if quoted",
"data": "\"a\tb\"@gmail.com",
"valid": true
},
{
"description": "quote inside quoted",
"data": "\"a\"b\"@gmail.com",
"valid": false
},
{
"description": "backslash inside quoted",
"data": "\"a\\b\"@gmail.com",
"valid": false
}
]
}
]

View File

@ -0,0 +1,23 @@
[
{
"description": "validation of time strings",
"schema": { "format": "time" },
"tests": [
{
"description": "contains alphabets",
"data": "ab:cd:efZ",
"valid": false
},
{
"description": "no digit in second fraction",
"data": "23:20:50.Z",
"valid": false
},
{
"description": "alphabets in offset",
"data": "08:30:06+ab:cd",
"valid": false
}
]
}
]

View File

@ -0,0 +1,26 @@
[
{
"description": "special characters",
"schema": {
"properties": {
"a%20b/c": { "type": "number" }
}
},
"tests": [
{
"description": "valid",
"data": {
"a%20b/c": 1
},
"valid": true
},
{
"description": "invalid",
"data": {
"a%20b/c": "hello"
},
"valid": false
}
]
}
]

View File

@ -0,0 +1,74 @@
[
{
"description": "percent-encoded json-pointer",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"a b": {"type": "number"}
},
"$ref": "#/$defs/a%20b"
},
"tests": [
{
"description": "match",
"data": 1,
"valid": true
},
{
"description": "mismatch",
"data": "foobar",
"valid": false
}
]
},
{
"description": "precent in resource ptr",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"a%20b": {
"$id": "http://temp.com/ab",
"type": "number"
}
},
"$ref": "http://temp.com/ab"
},
"tests": [
{
"description": "match",
"data": 1,
"valid": true
},
{
"description": "mismatch",
"data": "foobar",
"valid": false
}
]
},
{
"description": "precent in anchor ptr",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"a%20b": {
"$anchor": "abcd",
"type": "number"
}
},
"$ref": "#abcd"
},
"tests": [
{
"description": "match",
"data": 1,
"valid": true
},
{
"description": "mismatch",
"data": "foobar",
"valid": false
}
]
}
]

View File

@ -0,0 +1,57 @@
[
{
"description": "unevaluatedProperties with a failing $ref",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"child": {
"type": "object",
"properties": {
"prop2": { "type": "string" }
},
"unevaluatedProperties": false
}
},
"type": "object",
"properties": {
"prop1": { "type": "string" },
"child_schema": { "$ref": "#/$defs/child" }
},
"unevaluatedProperties": false
},
"tests": [
{
"description": "unevaluated property in child should fail validation",
"data": {
"prop1": "value1",
"child_schema": {
"prop2": "value2",
"extra_prop_in_child": "this should fail"
}
},
"valid": false
},
{
"description": "a valid instance should pass",
"data": {
"prop1": "value1",
"child_schema": {
"prop2": "value2"
}
},
"valid": true
},
{
"description": "unevaluated property in parent should fail",
"data": {
"prop1": "value1",
"child_schema": {
"prop2": "value2"
},
"extra_prop_in_parent": "this should fail"
},
"valid": false
}
]
}
]

View File

@ -0,0 +1,21 @@
[
{
"description": "zero fraction",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"uniqueItems": true
},
"tests": [
{
"description": "with fraction",
"data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 2.0],
"valid": false
},
{
"description": "without fraction",
"data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 2],
"valid": false
}
]
}
]

View File

@ -0,0 +1,27 @@
[
{
"description": "percent in dependencies",
"schema": {
"dependencies": {
"a%20b": { "required": ["x"] }
}
},
"tests": [
{
"description": "valid",
"data": {
"a%20b": null,
"x": 1
},
"valid": true
},
{
"description": "invalid",
"data": {
"a%20b": null
},
"valid": false
}
]
}
]

View File

@ -0,0 +1,50 @@
[
{
"description": "skip then when if is false",
"schema": {
"if": false,
"then": {
"$ref": "blah/blah.json"
},
"else": {
"type": "number"
}
},
"tests": [
{
"description": "number is valid",
"data": 0,
"valid": true
},
{
"description": "string is invalid",
"data": "hello",
"valid": false
}
]
},
{
"description": "skip else when if is true",
"schema": {
"if": true,
"then": {
"type": "number"
},
"else": {
"$ref": "blah/blah.json"
}
},
"tests": [
{
"description": "number is valid",
"data": 0,
"valid": true
},
{
"description": "string is invalid",
"data": "hello",
"valid": false
}
]
}
]

View File

@ -0,0 +1,98 @@
[
{
"description": "validation of period",
"schema": { "format": "period" },
"tests": [
{
"description": "all string formats ignore integers",
"data": 12,
"valid": true
},
{
"description": "all string formats ignore floats",
"data": 13.7,
"valid": true
},
{
"description": "all string formats ignore objects",
"data": {},
"valid": true
},
{
"description": "all string formats ignore arrays",
"data": [],
"valid": true
},
{
"description": "all string formats ignore booleans",
"data": false,
"valid": true
},
{
"description": "all string formats ignore nulls",
"data": null,
"valid": true
},
{
"description": "both-explicit",
"data": "1963-06-19T08:30:06Z/1963-06-19T08:30:07Z",
"valid": true
},
{
"description": "start-explicit",
"data": "1963-06-19T08:30:06Z/P4DT12H30M5S",
"valid": true
},
{
"description": "end-explicit",
"data": "P4DT12H30M5S/1963-06-19T08:30:06Z",
"valid": true
},
{
"description": "none-explicit",
"data": "P4DT12H30M5S/P4DT12H30M5S",
"valid": false
},
{
"description": "just date",
"data": "1963-06-19T08:30:06Z",
"valid": false
},
{
"description": "just duration",
"data": "P4DT12H30M5S",
"valid": false
},
{
"description": "more than two",
"data": "1963-06-19T08:30:06Z/1963-06-19T08:30:07Z/1963-06-19T08:30:07Z",
"valid": false
},
{
"description": "separated by space",
"data": "1963-06-19T08:30:06Z 1963-06-19T08:30:07Z",
"valid": false
},
{
"description": "separated by hyphen",
"data": "1963-06-19T08:30:06Z-1963-06-19T08:30:07Z",
"valid": false
},
{
"description": "invalid components",
"data": "foo/bar",
"valid": false
},
{
"description": "emtpy components",
"data": "/",
"valid": false
},
{
"description": "empty string",
"data": "",
"valid": false
}
]
}
]