trying to make the post request into the scripts

This commit is contained in:
filipriec
2025-03-08 11:51:26 +01:00
parent 53ab9ad7d7
commit 8ad2179d86
7 changed files with 342 additions and 15 deletions

View File

@@ -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(())
}