Skip to main content

boundary_compiler/
schema.rs

1//! Optional JSON Schema validation before and after JCS canonicalization.
2//!
3//! This module provides a `SchemaValidator` that can validate JSON values
4//! against JSON Schema before and/or after canonicalization. It's designed
5//! for boundary profiles that require schema conformance as part of
6//! their transformation pipeline.
7//!
8//! The base crate has no schema engine, so schema-required admission fails closed.
9
10use crate::error::JcsError;
11
12/// JSON Schema validator companion to BoundaryProfile.
13///
14/// Fail-closed marker for schema-required admission in the base crate.
15#[derive(Debug, Clone, Default)]
16pub struct SchemaValidator;
17
18impl SchemaValidator {
19    /// Creates a validator marker.
20    pub fn new() -> Self {
21        Self
22    }
23
24    /// Refuses admission because no schema engine/schema is configured.
25    pub fn validate(&self, _value: &serde_json::Value) -> Result<(), JcsError> {
26        Err(JcsError::SchemaError(
27            "schema validation is unavailable; refusing schema-required admission".into(),
28        ))
29    }
30}