[ { "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", "values": { "field_name": "email" }, "details": { "path": "email", "schema": "full.person" } } ] } } ] }, { "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", "values": { "count": "26", "limit": "5" }, "details": { "path": "email", "schema": "full.person" } } ] } } ] }, { "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", "values": { "include": "nonexistent_trait" }, "details": { "path": "full.person", "schema": "full.person" } } ] } } ] }, { "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", "values": { "include": "trait_a" }, "details": { "path": "full.person/include/trait_a/include/trait_b", "schema": "full.person" } } ] } } ] } ]