192 lines
4.2 KiB
JSON
192 lines
4.2 KiB
JSON
[
|
|
{
|
|
"description": "Granular trait composition and list merging",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "person",
|
|
"schemas": {
|
|
"full.person": {
|
|
"type": "object",
|
|
"include": ["emailable", "phonable"],
|
|
"properties": {
|
|
"name": { "type": "string" }
|
|
},
|
|
"required": ["name"]
|
|
}
|
|
},
|
|
"traits": {
|
|
"emailable": {
|
|
"properties": {
|
|
"email": { "type": "string" }
|
|
},
|
|
"required": ["email"],
|
|
"display": ["email"]
|
|
},
|
|
"phonable": {
|
|
"properties": {
|
|
"phone": { "type": "string" }
|
|
},
|
|
"required": ["phone"],
|
|
"display": ["phone"]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid person with name, email, and phone passes",
|
|
"schema_id": "full.person",
|
|
"action": "validate",
|
|
"data": {
|
|
"name": "Jane Doe",
|
|
"email": "jane@example.com",
|
|
"phone": "555-1234"
|
|
},
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "missing email fails validation",
|
|
"schema_id": "full.person",
|
|
"action": "validate",
|
|
"data": {
|
|
"name": "Jane Doe",
|
|
"phone": "555-1234"
|
|
},
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "REQUIRED_FIELD_MISSING",
|
|
"details": {
|
|
"path": "email"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Local property shadowing",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "person",
|
|
"schemas": {
|
|
"full.person": {
|
|
"type": "object",
|
|
"include": ["emailable"],
|
|
"properties": {
|
|
"email": {
|
|
"type": "string",
|
|
"maxLength": 5
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"traits": {
|
|
"emailable": {
|
|
"properties": {
|
|
"email": { "type": "string" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "local maxLength overrides trait properties",
|
|
"schema_id": "full.person",
|
|
"action": "validate",
|
|
"data": {
|
|
"email": "longerthanfive@example.com"
|
|
},
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "MAX_LENGTH_VIOLATED",
|
|
"details": {
|
|
"path": "email"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Missing trait compiler error",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "person",
|
|
"schemas": {
|
|
"full.person": {
|
|
"type": "object",
|
|
"include": ["nonexistent_trait"]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "emits TRAIT_NOT_FOUND compile error",
|
|
"action": "compile",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "TRAIT_NOT_FOUND"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Circular inclusion compiler error",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "person",
|
|
"schemas": {
|
|
"full.person": {
|
|
"type": "object",
|
|
"include": ["trait_a"]
|
|
}
|
|
},
|
|
"traits": {
|
|
"trait_a": {
|
|
"include": ["trait_b"]
|
|
},
|
|
"trait_b": {
|
|
"include": ["trait_a"]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "emits CIRCULAR_INCLUDE_DETECTED compile error",
|
|
"action": "compile",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CIRCULAR_INCLUDE_DETECTED"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|