check 規則
check 驗證單一 stored scalar 的值。它適合數值界線、文字格式與有限集合,例如金額不得為負、代碼符合固定格式,或風險等級只能在產品允許的集合中。
Payload
{
"type": "check",
"name": "訂單編號格式",
"column": "訂單編號",
"op": "matches",
"value": "^ORD-[0-9]{6}$",
"when": [
{ "column": "狀態", "op": "neq", "value": "草稿" }
]
}可用 operator:
- 比較:
lt、lte、gt、gte、eq、neq - Regex:
matches,僅限 string、text、select,pattern 最多 512 字元 - 集合:
in、not_in,非空陣列最多 50 個值
Boolean 只支援 eq、neq、in、not_in。所有 literal 都必須符合欄位型別。
空值不是格式錯誤
欄位是 null 或空字串時,check 不否決。若需求是「有值且格式正確」,請組合 require 與 check;若只在某狀態需要,兩條規則可共用同一組 when。
使用 rules.preview 驗證 regex 與既有樣本,再由 rules.set 發布。
Last updated on