Module validate

Module validate 

Source
Expand description

Document schema validation

§Architecture

Validation is built on DocumentParser composition:

  • SchemaValidator: Dispatches to type-specific validators based on SchemaNodeContent
  • Type validators: Implement DocumentParser<Output = (), Error = ValidatorError>
  • ValidationContext: Manages shared state (errors, warnings, path)

§Error Handling

Two categories of errors:

  • ValidationError: Type mismatches accumulated in ValidationContext (non-fatal)
  • ValidatorError: Internal validator errors causing fail-fast (e.g., undefined references)

§Hole Values

The hole value (!) represents an unfilled placeholder:

  • Type checking: Holes match any schema (always pass)
  • Completeness: Documents containing holes are valid but not complete

Structs§

SchemaValidator
Main validator that dispatches to type-specific validators.
ValidationContext
Validation context combining schema reference and mutable state.
ValidationOutput
Final validation output returned to callers.
ValidationState
Internal mutable state during validation.

Enums§

UnionTagMode
Mode for union tag resolution.
ValidationError
Type errors accumulated during validation.
ValidationWarning
Warnings generated during validation.
ValidatorError
Internal validator errors that cause immediate failure.

Functions§

validate
Validate a document against a schema.
validate_node
Validate a specific node against a schema node.
validate_node_with_mode
Validate a specific node against a schema node with the specified union tag mode.
validate_with_mode
Validate a document against a schema with the specified union tag mode.