Thoryn

Policy rules · Policy rules

Age-over-21 gate

Same shape as age-over-18, with the threshold raised. Use it for jurisdictions or product categories where 21 is the legal floor (US alcohol, some financial-services flows).

Tested against:policyEngine: 1.0.0

policy-engine recipe — shared category architecture: how this pattern composes with Hub, Broker, and the rest of the catalog

Use case

US-jurisdiction alcohol or some regulated financial-services products require age 21+. The wallet's derived age_over_21 claim mirrors age_over_18 — a boolean computed by the wallet without disclosing the birth date.

Rule

{
  "fact": "age_over_21",
  "operator": "equal",
  "value": true
}

Facts shape

data class AgeFacts(val age_over_21: Boolean)

Evaluation

val facts = mapOf("age_over_21" to vpClaims["age_over_21"])
val decision = policyEngine.evaluate(rule, facts)

Trace — DENY

When the holder is 19 and the wallet returns age_over_21 = false:

{
  "decision": "DENY",
  "reason": "age_over_21 expected true, got false",
  "trace": [
    { "fact": "age_over_21", "operator": "equal", "value": true, "result": "fail" }
  ]
}

When to use

  • US alcohol / cannabis / firearms flows
  • Regulated financial onboarding where 21 is the floor (US securities-related products)

When not to use

  • You operate in a jurisdiction where 18 is sufficient — use age-over-18

See also