Skip to main content

shape_runtime/semantic/
validator.rs

1//! Semantic validation rules for Shape
2
3/// Validator for semantic rules
4pub struct Validator {
5    /// Source code for error location reporting (optional)
6    source: Option<String>,
7}
8
9impl Validator {
10    /// Create a new validator with default configuration
11    pub fn new() -> Self {
12        Self { source: None }
13    }
14
15    /// Set the source code for better error location reporting
16    pub fn with_source(mut self, source: impl Into<String>) -> Self {
17        self.source = Some(source.into());
18        self
19    }
20
21    /// Set the source code (mutable reference version)
22    pub fn set_source(&mut self, source: impl Into<String>) {
23        self.source = Some(source.into());
24    }
25}
26
27impl Default for Validator {
28    fn default() -> Self {
29        Self::new()
30    }
31}