Core Concepts: The Validation Engine
Understanding the determinism behind SchemaInterface's parsing and evaluation model.
The Validation Lifecycle
SchemaInterface does not use regular expressions for structural validation. We compile schemas into an intermediate Abstract Syntax Tree (AST) that enforces deterministic state machine transitions. This prevents catastrophic backtracking attacks (ReDoS) commonly found in naive validators.
- Lexical Analysis: The JSON payload is parsed strictly (no trailing commas, no unquoted keys).
- Reference Resolution: All internal
$refand$dynamicRefpointers are resolved. External references require explicit configuration. - Constraint Application: Type constraints, then structural constraints (properties, items), then format assertions.
Type Mapping & Generation
When using the Code Generator, SchemaInterface applies strict mappings to target languages. Nullable types are handled via Option/Optional wrappers rather than loose typing.
| JSON Schema | TypeScript | Rust |
|---|---|---|
| "type": "string" | string | String |
| "type": ["string", "null"] | string | null | Option<String> |
| "format": "date-time" | Date | chrono::DateTime |
Resolution ($ref) Architecture
Cyclic dependencies in JSON Schema are valid but require careful evaluation. Our engine limits recursion depth to 128 levels by default to prevent stack overflows.
{
"type": "object",
"properties": {
"parent": { "$ref": "#" }
}
}Fig 1: A structurally valid self-referential schema representing an infinitely nested tree.