28 lines
719 B
Rust
28 lines
719 B
Rust
// src/steel/validation/script.rs
|
|
use std::fmt;
|
|
|
|
#[derive(Debug)]
|
|
pub enum ScriptValidationError {
|
|
EmptyScript,
|
|
InvalidSyntax(String),
|
|
}
|
|
|
|
impl fmt::Display for ScriptValidationError {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
Self::EmptyScript => write!(f, "Script cannot be empty"),
|
|
Self::InvalidSyntax(msg) => write!(f, "Syntax error: {}", msg),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn validate_script(script: &str) -> Result<(), ScriptValidationError> {
|
|
// Check for empty script
|
|
if script.trim().is_empty() {
|
|
return Err(ScriptValidationError::EmptyScript);
|
|
}
|
|
|
|
// If we get here, the script passed basic validation
|
|
Ok(())
|
|
}
|