Skip to main content

is_group

Function is_group 

Source
pub fn is_group(step: &Value) -> bool
Expand description

Whether this authored step element parses as a task group.

The test is presence of a tasks key, nothing else — the same test the parser makes. In particular a tasks key holding a non-array is still a group, and a malformed one: the parser will reject it as a bad group rather than silently reading it as a task.

An element carrying neither tasks nor function is not a group, so a caller reports a broken task — which is what the parser’s own diagnostic says (missing field 'function').

use dataflow_rs::engine::steps::is_group;
use serde_json::json;

assert!(is_group(&json!({"id": "g", "tasks": []})));
assert!(
    is_group(&json!({"id": "g", "tasks": "oops"})),
    "presence of the key, not its type — this is a malformed group"
);
assert!(!is_group(&json!({"id": "t", "function": {"name": "map"}})));
assert!(!is_group(&json!({"id": "t"})), "neither key: a broken task");
assert!(!is_group(&json!("not even an object")));