use nodedb_types::Value;
pub fn str_arg(args: &[Value], idx: usize) -> Option<String> {
match args.get(idx)? {
Value::String(s) => Some(s.clone()),
Value::Uuid(s) | Value::Ulid(s) | Value::Regex(s) => Some(s.clone()),
Value::DateTime(dt) => Some(dt.to_iso8601()),
Value::Duration(d) => Some(d.to_human()),
_ => None,
}
}
pub fn num_arg(args: &[Value], idx: usize) -> Option<f64> {
args.get(idx)
.and_then(|v| crate::value_ops::value_to_f64(v, true))
}
pub fn bool_id_check(args: &[Value], check: impl Fn(&str) -> bool) -> Value {
args.first()
.and_then(|v| v.as_str())
.map_or(Value::Bool(false), |s| Value::Bool(check(s)))
}