Skip to main content

peat_schema/validation/
mod.rs

1//! Schema validation utilities
2//!
3//! This module provides validation functions for Peat Protocol messages to ensure:
4//! - Confidence scores are within valid range (0.0 - 1.0)
5//! - Required fields are present
6//! - Semantic constraints are satisfied
7//! - CRDT invariants are maintained
8
9mod actuator;
10mod capability;
11mod command;
12mod core;
13mod effector;
14mod model;
15mod product;
16mod sensor;
17mod tasking;
18mod track;
19
20/// Validation error types
21#[derive(Debug, thiserror::Error)]
22pub enum ValidationError {
23    #[error("Invalid confidence score: {0} (must be between 0.0 and 1.0)")]
24    InvalidConfidence(f32),
25
26    #[error("Missing required field: {0}")]
27    MissingField(String),
28
29    #[error("Invalid field value: {0}")]
30    InvalidValue(String),
31
32    #[error("Semantic constraint violated: {0}")]
33    ConstraintViolation(String),
34}
35
36pub type ValidationResult<T> = Result<T, ValidationError>;
37
38// Re-export all validators
39pub use actuator::*;
40pub use capability::*;
41pub use command::*;
42pub use core::*;
43pub use effector::*;
44pub use model::*;
45pub use product::*;
46pub use sensor::*;
47pub use tasking::*;
48pub use track::*;