Okyline Annex F Quick Reference - Virtual Fields

Version: 1.7.0 Date: May 2026 Status: Draft

Companion to the Okyline Core Language Quick Reference. Covers virtual fields ($field) - computed properties usable as triggers in conditional directives. Requires Annex C ($compute).


F - Virtual Fields ($field)

Virtual fields inject computed properties into an object during validation, as if they were present in the JSON data - but they are derived from existing fields, not supplied by the producer. Typical use: compute a tier, a classification, or a flag, then use it as a trigger in conditional directives ($appliedIf, $requiredIf, etc.). They require $compute (Annex C).

F.1 Syntax

{
  "$oky": {
    "order": {
      "$field discountTier": "%CalculateTier",
      "total": 1500.00,
      "$appliedIf discountTier('GOLD')": {
        "loyaltyBonus|@": 50.00
      }
    }
  },
  "$compute": {
    "CalculateTier": "total >= 1000 ? 'GOLD' : 'STANDARD'"
  }
}

discountTier is computed, exists only during validation, used as condition trigger

Syntax: "$field <name>": "%<ComputeName>"


F.2 Rules


F.3 Chaining

Virtual fields evaluate sequentially in declaration order. Each can reference previously declared ones:

"$field subtotal": "%ComputeSubtotal",
"$field tax": "%ComputeTax",
"$field total": "%ComputeTotal"
"ComputeSubtotal": "price * quantity",
"ComputeTax": "subtotal * 0.2",
"ComputeTotal": "subtotal + tax"

tax uses subtotal, total uses both. Order matters.

Evaluation order: Parse → Virtual fields (in order) → Conditional directives → Field constraints


F.4 Usage in Conditionals

Directive Example
$requiredIf "$requiredIf tier('PREMIUM')": ["supportEmail"]
$requiredIfNot "$requiredIfNot active(true)": ["reason"]
$forbiddenIf "$forbiddenIf category('RESTRICTED')": ["publicUrl"]
$forbiddenIfNot "$forbiddenIfNot enabled(true)": ["legacyMode"]
$appliedIf "$appliedIf type('SPECIAL')": { ... }
$appliedIf (switch) "$appliedIf tier": { "('GOLD')": {...}, "('SILVER')": {...} }

Null test: "$requiredIf computedField(null)": ["fallback"]


F.5 Scope


F.6 $compute vs $field

$compute $field
Declared at Root level Object level
Value Expression string %ComputeName reference
Purpose Reusable expressions Derived values for conditions
Used via (%Name) in field constraints Name in condition triggers
Scope Global Local to declaring object

Okyline® is a registered trademark of Akwatype.