Skip to main content

parse_triggers

Function parse_triggers 

Source
pub fn parse_triggers(
    obj: &Map<String, Value>,
    owner: &str,
    fields: &HashMap<String, FieldDef>,
) -> Result<Triggers, String>
Expand description

解析并校验 schema 顶层的 triggers;任一项非法 → Err(零静默)。

校验清单(全部命中即 Err):

  1. triggers 非对象;
  2. 事件键不在 EVENTS;
  3. 事件值非数组 / 元素非对象;
  4. into/op/data(命令式)与 fnRef(回调式)互斥且必居其一;
  5. op 不在 OPS;
  6. 命令式缺 data,或 op=update 缺 condition;
  7. onFields 非字符串数组,或字段未在 fields 中声明($ 前缀键除外);
  8. when 非对象;出现 cascade 键(首批不支持级联);
  9. 命令式 data 的键未在目标 schema 中声明(在展开期校验,见 command::triggers)。