trying to make the post request into the scripts
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
// src/steel/validation/script.rs
|
||||
use steel_core::steel_vm::engine::Engine;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ScriptValidationError {
|
||||
EmptyScript,
|
||||
InvalidSyntax(String),
|
||||
MissingTransformFunction,
|
||||
}
|
||||
|
||||
impl fmt::Display for ScriptValidationError {
|
||||
@@ -14,7 +12,6 @@ impl fmt::Display for ScriptValidationError {
|
||||
match self {
|
||||
Self::EmptyScript => write!(f, "Script cannot be empty"),
|
||||
Self::InvalidSyntax(msg) => write!(f, "Syntax error: {}", msg),
|
||||
Self::MissingTransformFunction => write!(f, "Script must define a 'transform' function"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,14 +21,7 @@ pub fn validate_script(script: &str) -> Result<(), ScriptValidationError> {
|
||||
if script.trim().is_empty() {
|
||||
return Err(ScriptValidationError::EmptyScript);
|
||||
}
|
||||
|
||||
// Create a new Steel engine
|
||||
let mut engine = Engine::new();
|
||||
|
||||
// Check for the presence of a 'transform' function
|
||||
if engine.extract_value("transform").is_err() {
|
||||
return Err(ScriptValidationError::MissingTransformFunction);
|
||||
}
|
||||
|
||||
|
||||
// If we get here, the script passed basic validation
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user