Skip to content

Commit 5c58423

Browse files
claude[bot]claude
andauthored
docs(skills): state which record each validation rule type is judged against (#15046)
The rule-type table in skills/objectstack-data/rules/validation.md said what each type is for and when it fails, but never which record the predicate is evaluated on -- and the answer is not uniform across the six. An author who generalises "validations[] holds invariants" reaches for `format` to guard stored data and silently gets a write gate instead. Adds one column, "Judged against", each cell measured from evaluateRule's dispatch in packages/objectql/src/validation/rule-validator.ts: - script / cross_field -> ctx.merged, the prior row overlaid with the write - format / json_schema -> ctx.data, the write payload, behind a `field in data` guard, so an omitted field is never judged - state_machine -> ctx.data value against ctx.previous, same guard; the insert leg checks initialStates instead - conditional -> its `when` on ctx.merged, then the nested rule re-dispatched through the same switch Table only: no prose, heading, example or tool-choice changes. Net lines 0. Claude-Session: https://claude.ai/code/session_019RfFHiRCSs3JXLK4cwcfox Co-authored-by: Claude <noreply@anthropic.com>
1 parent b17cdea commit 5c58423

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

skills/objectstack-data/rules/validation.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Comprehensive guide for implementing validation rules in ObjectStack.
66

77
The **complete** set of `type` discriminators accepted by `ValidationRuleSchema`:
88

9-
| Type | Purpose | When Validation Fails |
10-
|:-----|:--------|:---------------------|
11-
| `script` | CEL predicate over the record | When predicate evaluates to `true` |
12-
| `state_machine` | Legal state transitions | When transition not allowed |
13-
| `format` | Regex or built-in format | When format doesn't match |
14-
| `cross_field` | CEL predicate comparing fields | When predicate evaluates to `true` |
15-
| `json_schema` | Validate JSON field | When JSON doesn't match schema |
16-
| `conditional` | Apply nested rule when a predicate holds | When nested rule fails |
9+
| Type | Purpose | When Validation Fails | Judged against |
10+
|:-----|:--------|:---------------------|:---------------|
11+
| `script` | CEL predicate over the record | When predicate evaluates to `true` | Merged record — prior row plus this write |
12+
| `state_machine` | Legal state transitions | When transition not allowed | Written value vs the prior row's, only when the write sets the field (insert: `initialStates`) |
13+
| `format` | Regex or built-in format | When format doesn't match | Write payload only — an omitted field is never judged |
14+
| `cross_field` | CEL predicate comparing fields | When predicate evaluates to `true` | Merged record — prior row plus this write |
15+
| `json_schema` | Validate JSON field | When JSON doesn't match schema | Write payload only — an omitted field is never judged |
16+
| `conditional` | Apply nested rule when a predicate holds | When nested rule fails | Its `when` on the merged record; the nested rule as its own type |
1717

1818
There is no other type. In particular:
1919

0 commit comments

Comments
 (0)