Expand description
What a hook handler returns to the host.
A hook’s Ok value is a JSON object the host reads as an instruction. These
helpers build it; anything else (including {} or null) means “carry on
unchanged”, so an observational hook can simply return
Ok(serde_json::Value::Null).
fn guard(ctx: &Context<()>, _input: serde_json::Value) -> Result<serde_json::Value, String> {
let Some(h) = ctx.hook() else { return Ok(reply::proceed()) };
if h.field("title").and_then(|t| t.as_str()).unwrap_or("").is_empty() {
return Ok(reply::abort(422, "title is required"));
}
Ok(reply::proceed())
}