DRDataRaft/ docs
GitHub ↗

H05 Add a business rule

H05Data, products and quality1 step

Use your current course session. Preparation and course runner · R script ↓

Now run the course runner from the script, immediately after H04. It defines training_step(), options and the training directory. Open the course runner →

H05 Add a business rule

Goal: Require nonnegative premiums.

Prerequisites: H04 and the course runner immediately after H04.

The contract checks structure. The named rule checks business content. Extend the definition, then run it again.

training_step(
  "H05",
  {
    policy_product <- dr_add_quality(
      policy_product,
      list(nonnegative = ~ premium >= 0)
    )
    policy_run <- dr_run(policy_product, write = FALSE)
    print(dr_quality_report(policy_run))
    stopifnot(policy_run$validation_status == "passed")
  },
  needs = c("H04")
)

Expected result: All configured checks pass.

Task: Is zero allowed?

Show solution

Yes: the rule is >= 0, not > 0. Next, introduce a bad delivery.

Search documentation

Search functions, packages and guides.