Skip to main content

golem_schema/schema/validation/
mod.rs

1// Copyright 2024-2026 Golem Cloud
2//
3// Licensed under the Golem Source License v1.1 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://license.golem.cloud/LICENSE
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Validation utilities for the in-memory schema model.
16//!
17//! Three core validators, each with its own error type:
18//!
19//! - [`well_formedness::validate_graph`] — structural integrity of a
20//!   [`super::SchemaGraph`] (no duplicate type ids, no dangling refs,
21//!   non-empty discriminated sums, well-formed scalar constraints, etc.).
22//! - [`value::validate_value`] — a [`super::SchemaValue`] structurally
23//!   conforms to a given [`super::SchemaType`] inside a graph.
24//! - [`subtyping::is_assignable`] — width / depth / scalar-narrowing
25//!   subtyping with cycle detection over [`super::SchemaType::Ref`].
26//!
27//! These validators are pure in-memory checks. They do not depend on the
28//! generated WIT bindings under [`super::wit`].
29
30pub mod subtyping;
31pub mod value;
32pub mod well_formedness;
33
34#[cfg(test)]
35mod tests;
36
37pub use subtyping::{is_assignable, is_equivalent_cross_graph};
38pub use value::{ValueError, ValuePath, ValuePathSegment, validate_value};
39pub use well_formedness::{SchemaError, validate_graph, validate_root_type};