|
4 | 4 | { |
5 | 5 | "id": 1, |
6 | 6 | "prompt": "Add a `full_name` formula on `contact` built from salutation, first name and last name, and a `margin_pct` formula on `deal` = (revenue - cost) / cost * 100.", |
7 | | - "expected_output": "Two `type: 'formula'` fields whose `expression` is CEL via the `F` tag. The text formula coalesces every nullable operand — `F`coalesce(record.salutation, '') + ' ' + coalesce(record.first_name, '') + ' ' + coalesce(record.last_name, '')`` — because `null + 'foo'` throws. The numeric one guards the divisor: `F`coalesce(record.cost, 0) > 0 ? ((coalesce(record.revenue, 0) - record.cost) * 100) / record.cost : 0.0``. Field references are bare `record.<field>`, never brace-wrapped.", |
| 7 | + "expected_output": "Two `type: 'formula'` fields whose `expression` is CEL via the `F` tag. The text formula coalesces every nullable operand — `F`coalesce(record.salutation, '') + ' ' + coalesce(record.first_name, '') + ' ' + coalesce(record.last_name, '')`` — because `null + 'foo'` throws. The numeric one guards the divisor: `F`coalesce(record.cost, 0) > 0 ? ((coalesce(record.revenue, 0) - record.cost) * 100) / record.cost : 0.0``.", |
8 | 8 | "files": [], |
9 | 9 | "assertions": { |
10 | 10 | "must_contain": ["F`", "coalesce(", "record."], |
|
14 | 14 | { |
15 | 15 | "id": 2, |
16 | 16 | "prompt": "Translate this Salesforce validation rule into ObjectStack: AND(ISBLANK(po_number), amount > 10000, NOT(ISPICKVAL(status, 'draft'))).", |
17 | | - "expected_output": "Applies the mechanical legacy → CEL table: `P`isBlank(record.po_number) && record.amount > 10000 && record.status != 'draft'``, noting that a `script` validation is inverted (it FAILS when the expression is true, so keep the failing condition) and that `record.amount > 10000` on a declared-nullable field needs an explicit `record.amount != null &&` guard or the publish gate rejects it. Uses `'draft'` single quotes and bare `record.` references.", |
| 17 | + "expected_output": "Applies the mechanical legacy → CEL table: `P`isBlank(record.po_number) && record.amount > 10000 && record.status != 'draft'``, noting that a `script` validation is inverted (it FAILS when the expression is true, so keep the failing condition) and that `record.amount > 10000` on a declared-nullable field needs an explicit `record.amount != null &&` guard or the publish gate rejects it.", |
18 | 18 | "files": [], |
19 | 19 | "assertions": { |
20 | 20 | "must_contain": ["isBlank(", "&&", "record.", "P`"], |
|
24 | 24 | { |
25 | 25 | "id": 3, |
26 | 26 | "prompt": "Run an automation only when a support case has just become `escalated` — on single updates and on bulk updates alike.", |
27 | | - "expected_output": "Writes it once as `P`previous.status != 'escalated' && record.status == 'escalated'``: `record` is the post-write state (true on every later update too), so only `previous` says \"just became\"; `previous` is bound per row on `before*`/`after*` update events, bulk too. On insert `previous` is `null`: the `previous.status` read faults and aborts the write, so to run on inserts guard with `previous != null &&`. No `ISCHANGED()` function.", |
| 27 | + "expected_output": "Writes it once as `P`previous.status != 'escalated' && record.status == 'escalated'``: `record` is the post-write state (true on every later update too), so only `previous` says \"just became\"; `previous` is bound per row on `before*`/`after*` update events, bulk too. On insert `previous` is `null`: the `previous.status` read faults and aborts the write, so to run on inserts guard with `previous != null &&`.", |
28 | 28 | "files": [], |
29 | 29 | "assertions": { |
30 | 30 | "must_contain": ["previous.status", "record.status", "!="], |
|
44 | 44 | { |
45 | 45 | "id": 5, |
46 | 46 | "prompt": "Hide `discount_reason` unless a discount amount was entered, and reject any `end_date` earlier than `start_date`.", |
47 | | - "expected_output": "`visibleWhen: P`record.discount != null`` (or `!isBlank(record.discount)`) on the field — `has(record.discount)` is not a null check: every declared field exists, so it is always true. The date rule is a `script` validation whose predicate dominates the comparison with explicit null tests: `record.start_date != null && record.end_date != null && record.end_date < record.start_date`; a `has()` guard does not satisfy the publish-time gate. Canonical property names only — never `conditionalRequired`.", |
| 47 | + "expected_output": "`visibleWhen: P`record.discount != null`` (or `!isBlank(record.discount)`) on the field — `has(record.discount)` is not a null check: every declared field exists, so it is always true. The date rule is a `script` validation whose predicate dominates the comparison with explicit null tests: `record.start_date != null && record.end_date != null && record.end_date < record.start_date`; a `has()` guard does not satisfy the publish-time gate.", |
48 | 48 | "files": [], |
49 | 49 | "assertions": { |
50 | 50 | "must_contain": ["visibleWhen", "!= null", "record.end_date"], |
51 | 51 | "must_not_contain": ["conditionalRequired:", "{record."] |
52 | 52 | } |
| 53 | + }, |
| 54 | + { |
| 55 | + "id": 6, |
| 56 | + "prompt": "Name `contract_version` records by their version number and the `kind` select, so a zh-CN reader sees `v2 · 清稿` and an en-US reader `v2 · Clean`.", |
| 57 | + "expected_output": "A `type: 'formula'` `nameField`: `F`'v' + string(record.version_no) + ' · ' + label(record.kind)``. `label()` takes exactly `record.<field>` of a select field and reads its option label in the reader's locale (`''` for null). The stored value is the same in every locale, so a ternary over it with hard-coded strings cannot follow the reader.", |
| 58 | + "files": [], |
| 59 | + "assertions": { |
| 60 | + "must_contain": ["label(record.kind)", "F`"], |
| 61 | + "must_not_contain": ["== 'clean' ?", "{record."] |
| 62 | + } |
| 63 | + }, |
| 64 | + { |
| 65 | + "id": 7, |
| 66 | + "prompt": "Refuse a `contract_version` save unless its `kind` is the clean copy, and show `signed_at` only once `status` is signed.", |
| 67 | + "expected_output": "Both are predicates over the STORED value: a `script` validation `P`record.kind != 'clean'`` (it fails when true) and `visibleWhen: P`record.status == 'signed'``. The `label` macro evaluates only in a formula field; in a validation, `visibleWhen` or hook predicate it faults and aborts every write, so compare the stored value, never its option label.", |
| 68 | + "files": [], |
| 69 | + "assertions": { |
| 70 | + "must_contain": ["record.kind", "visibleWhen", "P`"], |
| 71 | + "must_not_contain": ["label(", "{record."] |
| 72 | + } |
53 | 73 | } |
54 | 74 | ] |
55 | 75 | } |
0 commit comments