removed schema realms, fixed fixture generations, added dynamic type resolution for validation based on type and kind discriminators for filters

This commit is contained in:
2026-04-21 10:50:01 -04:00
parent a1e6ac8cb0
commit 4e2cb488cc
25 changed files with 440 additions and 331 deletions

155
fixtures/dynamicType.json Normal file
View File

@ -0,0 +1,155 @@
[
{
"description": "Dynamic type binding ($sibling.suffix) validation",
"database": {
"types": [
{
"name": "person",
"schemas": {
"person.filter": {
"properties": {
"age": {
"type": "integer"
}
}
}
}
},
{
"name": "widget",
"schemas": {
"widget.filter": {
"properties": {
"weight": {
"type": "integer"
}
}
}
}
},
{
"name": "search",
"schemas": {
"search": {
"properties": {
"kind": {
"type": "string"
},
"filter": {
"type": "$kind.filter"
}
}
}
}
}
]
},
"tests": [
{
"description": "Valid person filter payload",
"data": {
"kind": "person",
"filter": {
"age": 30
}
},
"schema_id": "search",
"action": "validate",
"expect": {
"success": true
}
},
{
"description": "Invalid person filter payload (fails constraint)",
"data": {
"kind": "person",
"filter": {
"age": "thirty"
}
},
"schema_id": "search",
"action": "validate",
"expect": {
"success": false,
"errors": [
{
"code": "INVALID_TYPE",
"details": {
"path": "filter/age"
}
}
]
}
},
{
"description": "Valid widget filter payload",
"data": {
"kind": "widget",
"filter": {
"weight": 500
}
},
"schema_id": "search",
"action": "validate",
"expect": {
"success": true
}
},
{
"description": "Fails resolution if kind doesn't match an existing schema",
"data": {
"kind": "unknown",
"filter": {
"weight": 500
}
},
"schema_id": "search",
"action": "validate",
"expect": {
"success": false,
"errors": [
{
"code": "DYNAMIC_TYPE_RESOLUTION_FAILED",
"details": {
"path": "filter"
}
},
{
"code": "STRICT_PROPERTY_VIOLATION",
"details": {
"path": "filter/weight"
}
}
]
}
},
{
"description": "Fails resolution if discriminator is missing",
"data": {
"filter": {
"weight": 500
}
},
"schema_id": "search",
"action": "validate",
"expect": {
"success": false,
"errors": [
{
"code": "DYNAMIC_TYPE_RESOLUTION_FAILED",
"details": {
"path": "filter"
}
},
{
"code": "STRICT_PROPERTY_VIOLATION",
"details": {
"path": "filter/weight"
}
}
]
}
}
]
}
]

View File

@ -107,17 +107,17 @@
"search": {
"type": "object",
"properties": {
"kind": {
"type": "string"
},
"name": {
"type": "string"
},
"filter": {
"type": "filter"
"type": "$kind.filter"
}
}
},
"filter": {
"type": "object"
},
"condition": {
"type": "object",
"properties": {
@ -172,7 +172,7 @@
"schemas": {
"person": {},
"person.filter": {
"type": "filter",
"type": "object",
"compiledPropertyNames": [
"$and",
"$or",
@ -244,7 +244,7 @@
},
"address": {},
"address.filter": {
"type": "filter",
"type": "object",
"compiledPropertyNames": [
"$and",
"$or",
@ -287,18 +287,18 @@
}
}
},
"filter": {},
"condition": {},
"string.condition": {},
"integer.condition": {},
"date.condition": {},
"search": {},
"search.filter": {
"type": "filter",
"type": "object",
"compiledPropertyNames": [
"$and",
"$or",
"filter",
"kind",
"name"
],
"properties": {
@ -312,6 +312,7 @@
"$and",
"$or",
"filter",
"kind",
"name"
],
"type": "search.filter"
@ -327,6 +328,7 @@
"$and",
"$or",
"filter",
"kind",
"name"
],
"type": "search.filter"
@ -334,7 +336,13 @@
},
"filter": {
"type": [
"filter.filter",
"$kind.filter.filter",
"null"
]
},
"kind": {
"type": [
"string.condition",
"null"
]
},