feat!: added mostly foundational code, and a playground of sorts to interact with it

This commit is contained in:
selene 2025-11-24 01:05:58 +01:00
parent 6c524b0741
commit 9a28c1a1dd
Signed by: sel
SSH key fingerprint: SHA256:33R/4Rx5Lu4o81LyJyXdMrmP5CJ6j7j1Soo0Dn7mKc0
10 changed files with 417 additions and 0 deletions

View file

@ -0,0 +1,41 @@
use serde_json::json;
use crate::ObjectInstance;
pub const TEMPLATE: &str = r#"
[input.value]
transforms = []
subobjects = []
conditions = []
duplicates = false
[local.length]
transforms = ["meta/number:value"]
subobjects = []
conditions = []
duplicates = false
"#;
pub fn validate(obj: &ObjectInstance) -> Result<(), String> {
let value = obj.input.get("value")
.ok_or("input.value must exist")?;
let _value = value.as_str()
.ok_or("input.value must be a string")?;
Ok(())
}
pub fn local(obj: &ObjectInstance) -> Result<ObjectInstance, String> {
let value = obj.input.get("value")
.ok_or("input.value must exist")?;
let value = value.as_str()
.ok_or("input.value must be a string")?;
let mut new = obj.clone();
new.local = json!({
"length": value.len()
});
Ok(new)
}