Path-Based Schema Test Specifications
Test cases for path-based property validation using schema definitions.
Test Case: PATHSCHEMA_001 - Deep Nested Path Validation
Purpose
Test validation of deeply nested properties using path-based schemas.
Input Document
{(user)
name = "John",
email = "[email protected]",
details = {
bio = "Software engineer",
avatar = "avatar.jpg"
}
}
Schema Definition
#! {(user)
/name = string(required, minLength(1), maxLength(100)),
/email = string(required, format(email)),
/details/bio = string(maxLength(1000)),
/details/avatar = string(maxLength(255))
}
Expected Result
- Validation passes
- All path-based rules applied correctly
- Nested paths resolved properly
Test Case: PATHSCHEMA_002 - Missing Nested Required Property
Purpose
Test validation failure when required nested property is missing.
Input Document
{(user)
name = "John",
details = {
avatar = "avatar.jpg"
}
}
Schema Definition
#! {(user)
/name = string(required),
/details/bio = string(required),
/details/avatar = string(required)
}
Expected Result
- Validation fails
- Error count: 1
- Error message: "Required property 'bio' is missing"
- Error path: "/details/bio"
Test Case: PATHSCHEMA_003 - Numeric Property Paths
Purpose
Test validation of properties with numeric names using paths.
Input Document
{(inventory)
123 = "Special numbered item",
42name = "Answer item",
2024data = [1.5, 2.0, 3.5]
}
Schema Definition
#! {(inventory)
/123 = string(maxLength(50)),
/42name = string(minLength(5)),
/2024data = array:float(maxCount(5))
}
Expected Result
- Validation passes
- Numeric property names validated correctly
- Array validation with base type works
Test Case: PATHSCHEMA_004 - Array Type Validation
Purpose
Test validation of arrays with specified base types.
Input Document
{(project)
tags = ["javascript", "typescript", "nodejs"],
scores = [85.5, 92.0, 78.5],
flags = [true, false, true]
}
Schema Definition
#! {(project)
/tags = array:string(minCount(1), maxCount(10)),
/scores = array:float(minCount(1), range(0.0, 100.0)),
/flags = array:boolean(maxCount(5))
}
Expected Result
- Validation passes
- Array element types validated
- Count constraints applied
- Range validation for numeric arrays
Test Case: PATHSCHEMA_005 - Array Wrong Element Type
Purpose
Test validation failure when array contains wrong element type.
Input Document
{(test)
numbers = [1, 2, "three", 4]
}
Schema Definition
#! {(test)
/numbers = array:int(required)
}
Expected Result
- Validation fails
- Error: Element at index 2 is not of type int
- Path: "/numbers[2]"
Test Case: PATHSCHEMA_006 - Wildcard Path Matching
Purpose
Test wildcard path matching for dynamic property validation.
Input Document
{(config)
server1 = {
host = "192.168.1.1",
port = 8080
},
server2 = {
host = "192.168.1.2",
port = 8081
}
}
Schema Definition
#! {(config)
/server*/host = string(required, format(ipv4)),
/server*/port = int(required, range(1, 65535))
}
Expected Result
- Validation passes
- Wildcard matches both server1 and server2
- Rules applied to all matching paths
Test Case: PATHSCHEMA_007 - Class-Scoped Validation
Purpose
Test validation scoped to specific class types.
Input Document
{(database)
name = "production",
{(connection)
host = "db.example.com",
port = 5432
},
{(cache)
host = "cache.example.com",
port = 6379
}
}
Schema Definition
#! {(connection)
/host = string(required),
/port = int(required, range(1, 65535))
}
#! {(cache)
/host = string(required),
/port = int(required, default(6379))
}
Expected Result
- Validation passes
- Connection class validated with its rules
- Cache class validated with its rules
- Different schemas applied based on class
Test Case: PATHSCHEMA_008 - Default Value Application
Purpose
Test application of default values for missing properties.
Input Document
{(settings)
name = "MyApp"
}
Schema Definition
#! {(settings)
/name = string(required),
/version = string(default("1.0.0")),
/enabled = boolean(default(true)),
/maxRetries = int(default(3))
}
Expected Result After Validation
{(settings)
name = "MyApp",
version = "1.0.0",
enabled = true,
maxRetries = 3
}
Missing properties populated with default values.
Test Case: PATHSCHEMA_009 - Complex Path Expressions
Purpose
Test complex path expressions with multiple levels.
Input Document
{(app)
modules = {
auth = {
providers = {
google = {
clientId = "abc123",
enabled = true
}
}
}
}
}
Schema Definition
#! {(app)
/modules/auth/providers/google/clientId = string(required, minLength(6)),
/modules/auth/providers/google/enabled = boolean(required)
}
Expected Result
- Validation passes
- Deep path resolution works
- 4-level nesting validated correctly
Test Case: PATHSCHEMA_010 - Array Index Validation
Purpose
Test validation of specific array indices.
Input Document
{(config)
servers = [
{ host = "server1.com", priority = 1 },
{ host = "server2.com", priority = 2 },
{ host = "server3.com", priority = 3 }
]
}
Schema Definition
#! {(config)
/servers = array(minCount(1), maxCount(10)),
/servers[0]/priority = int(equals(1)),
/servers[*]/host = string(required, format(hostname))
}
Expected Result
- Validation passes
- First server priority must be 1
- All servers must have valid hostnames
Implementation Notes
- Path resolution should handle forward slashes as separators
- Numeric property names treated as strings in paths
- Wildcard (*) matches any property name at that level
- Array indices use bracket notation: [0], [1], [*]
- Class-scoped schemas apply to all instances of that class
- Default values applied during validation, not parsing
Error Reporting
- Errors should include full path to problematic property
- Path format: /parent/child/property or /array[index]
- Clear messages indicating constraint violation
- Multiple errors collected, not fail-fast