- Rename fixtures/items.json to fixtures/array.json to better reflect array testing constraints. - Update reference paths in src/tests/fixtures.rs and across other fixture JSON files. - Remove unused HashMap import in src/validator/rules/dict.rs to resolve the compiler warning.
234 lines
5.4 KiB
JSON
234 lines
5.4 KiB
JSON
[
|
|
{
|
|
"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"
|
|
},
|
|
"conditions": {
|
|
"type": "object",
|
|
"properties": {
|
|
"new": {
|
|
"type": "$kind.filter"
|
|
},
|
|
"old": {
|
|
"type": "$kind.filter"
|
|
},
|
|
"complete": {
|
|
"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",
|
|
"values": {
|
|
"expected": "integer"
|
|
},
|
|
"details": {
|
|
"path": "filter/age",
|
|
"schema": "search"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"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",
|
|
"values": {
|
|
"pointer": "unknown.filter"
|
|
},
|
|
"details": {
|
|
"path": "filter",
|
|
"schema": "search"
|
|
}
|
|
},
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"values": {
|
|
"property_name": "weight"
|
|
},
|
|
"details": {
|
|
"path": "filter/weight",
|
|
"schema": "search"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"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",
|
|
"values": {
|
|
"pointer": "$kind.filter",
|
|
"discriminator": "kind"
|
|
},
|
|
"details": {
|
|
"path": "filter",
|
|
"schema": "search"
|
|
}
|
|
},
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"values": {
|
|
"property_name": "weight"
|
|
},
|
|
"details": {
|
|
"path": "filter/weight",
|
|
"schema": "search"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Valid nested filter payload",
|
|
"data": {
|
|
"kind": "person",
|
|
"conditions": {
|
|
"new": {
|
|
"age": 30
|
|
}
|
|
}
|
|
},
|
|
"schema_id": "search",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "Invalid nested filter payload (fails constraint)",
|
|
"data": {
|
|
"kind": "person",
|
|
"conditions": {
|
|
"new": {
|
|
"age": "thirty"
|
|
}
|
|
}
|
|
},
|
|
"schema_id": "search",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"values": {
|
|
"expected": "integer"
|
|
},
|
|
"details": {
|
|
"path": "conditions/new/age",
|
|
"schema": "search"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
] |