neo_solidity/
validation.rs

1//! Input Validation Module
2//!
3//! Validates compiler inputs and configurations.
4
5use crate::error::CompilerError;
6
7/// Validation result
8pub type ValidationResult<T> = Result<T, Vec<CompilerError>>;
9
10/// Input validator
11#[derive(Default)]
12pub struct InputValidator {
13    errors: Vec<CompilerError>,
14}
15
16impl InputValidator {
17    pub fn new() -> Self {
18        Self::default()
19    }
20
21    pub fn validate_source(&mut self, source: &str) -> bool {
22        if source.is_empty() {
23            self.errors
24                .push(CompilerError::ParseError("Empty source file".to_string()));
25            return false;
26        }
27        if source.len() > 10_000_000 {
28            self.errors.push(CompilerError::ParseError(
29                "Source file too large (>10MB)".to_string(),
30            ));
31            return false;
32        }
33        true
34    }
35
36    pub fn errors(&self) -> &[CompilerError] {
37        &self.errors
38    }
39
40    pub fn has_errors(&self) -> bool {
41        !self.errors.is_empty()
42    }
43}