massively improves the jspg validator by removing mathmatical functions like allOf, anyOf, ref, etc to effectively use discriminators and OOP with types to determine valid pathing an nno intersections, unions, or guesswork; added cases to replace the former conditionals

This commit is contained in:
2026-04-08 13:08:24 -04:00
parent e4286ac6a9
commit 7c8df22709
30 changed files with 2526 additions and 4816 deletions

167
fixtures/objectTypes.json Normal file
View File

@ -0,0 +1,167 @@
[
{
"description": "Strict Inheritance",
"database": {
"schemas": [
{
"$id": "parent_type",
"type": "object",
"properties": {"a": {"type": "integer"}},
"required": ["a"]
},
{
"$id": "child_type",
"type": "parent_type",
"properties": {"b": {"type": "integer"}}
}
]
},
"tests": [
{
"description": "valid child inherits properties and strictness",
"schema_id": "child_type",
"data": {"a": 1, "b": 2},
"action": "validate",
"expect": {"success": true}
},
{
"description": "missing inherited required property fails",
"schema_id": "child_type",
"data": {"b": 2},
"action": "validate",
"expect": {"success": false}
},
{
"description": "additional properties fail due to inherited strictness",
"schema_id": "child_type",
"data": {"a": 1, "b": 2, "c": 3},
"action": "validate",
"expect": {"success": false}
}
]
},
{
"description": "Local Shadowing (Composition & Proxies)",
"database": {
"schemas": [
{
"$id": "budget",
"type": "object",
"properties": {
"max": {"type": "integer", "maximum": 100}
}
},
{
"$id": "custom_budget",
"type": "budget",
"properties": {
"max": {"type": "integer", "maximum": 50}
}
}
]
},
"tests": [
{
"description": "shadowing override applies (50 is locally allowed)",
"schema_id": "custom_budget",
"data": {"max": 40},
"action": "validate",
"expect": {"success": true}
},
{
"description": "shadowing override applies natively, rejecting 60 even though parent allowed 100",
"schema_id": "custom_budget",
"data": {"max": 60},
"action": "validate",
"expect": {"success": false}
}
]
},
{
"description": "Inline id Resolution",
"database": {
"schemas": [
{
"$id": "api.request",
"type": "object",
"properties": {
"inline_obj": {
"$id": "inline_nested",
"type": "object",
"properties": {"foo": {"type": "string"}},
"required": ["foo"]
},
"proxy_obj": {
"type": "inline_nested"
}
}
}
]
},
"tests": [
{
"description": "proxy resolves and validates to the inline component",
"schema_id": "api.request",
"data": {
"inline_obj": {"foo": "bar"},
"proxy_obj": {"foo": "baz"}
},
"action": "validate",
"expect": {"success": true}
},
{
"description": "proxy resolves and catches violation targeting inline component constraints",
"schema_id": "api.request",
"data": {
"inline_obj": {"foo": "bar"},
"proxy_obj": {}
},
"action": "validate",
"expect": {"success": false}
}
]
},
{
"description": "Primitive Array Shorthand (Optionality)",
"database": {
"schemas": [
{
"$id": "invoice",
"type": "object",
"properties": {"amount": {"type": "integer"}},
"required": ["amount"]
},
{
"$id": "request",
"type": "object",
"properties": {
"inv": {"type": ["invoice", "null"]}
}
}
]
},
"tests": [
{
"description": "valid object passes shorthand inheritance check",
"schema_id": "request",
"data": {"inv": {"amount": 5}},
"action": "validate",
"expect": {"success": true}
},
{
"description": "null passes shorthand inheritance check",
"schema_id": "request",
"data": {"inv": null},
"action": "validate",
"expect": {"success": true}
},
{
"description": "invalid object fails inner constraints safely",
"schema_id": "request",
"data": {"inv": {"amount": "string"}},
"action": "validate",
"expect": {"success": false}
}
]
}
]