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).
$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).
{
"$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>"
%Name reference to $compute (no inline expressions)$appliedIf payload fields$requiredIf/$forbiddenIf field lists (they are not data fields)$appliedIf payloadsVirtual 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
| 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"]
$ref inclusion (must redeclare)$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.