Rule Cascade
LearnThe process, end to end

Check: lint and load checks

Run rcas check. It reads the YAML, runs every load-time check against the schema and runs the golden tests.

rcas check does everything a runtime does before it accepts a ruleset, and more. It checks that the YAML means the same in every parser, validates the document, resolves its parent, checks every path against the entity schema, and runs the golden tests. It exits with status 1 on any problem, so you run it before every commit and CI runs it on every pull request.

Hands-on

  1. Check both rulesets of the project. The parent of orders-eu.ruleset.yaml is found among the ruleset files next to it.

    rcas check (real output)
    $ rcas check orders.ruleset.yaml orders-eu.ruleset.yaml
    shop.orders@1.0.0  sha256:4583c90bbfca...  2 rules (1 client-safe), 1 params
      3 golden tests, 0 failed
    shop.orders.eu@1.0.0  sha256:b31b76fa5a5b...  2 rules (1 client-safe), 1 params
      2 golden tests, 0 failed
    [exit status 0]

    Each line names the ruleset, its version, the start of its checksum, how many rules reach the browser ("client-safe") and how many golden tests passed.

  2. Make a typing mistake on purpose. Change data.quantity in the assert to data.quantty:

    orders.ruleset.yaml (the typo)
    assert: { op: lte, args: [{ var: data.quantty }, { var: params.maxQuantity }] }
    rcas check (real output)
    $ rcas check orders.ruleset.yaml
    orders.ruleset.yaml: LOAD FAILED
      PATH_UNKNOWN: order.quantity.max path data.quantty is not in the Order schema
    [exit status 1]

    PATH_UNKNOWN means the path is not in the schema. Without this check the rule would read a field that never exists, get null, and never fire. Fix the typo.

Done when

  • rcas check exits with status 0 for every ruleset you changed.
  • It reports the number of golden tests you expect, with 0 failed.

Go deeper

Course overview

On this page