Okyline Core Quick Reference - Conditional Directives

Version: 1.8.0 Date: September 2026 Status: Draft

Companion to the Okyline Core Quick Reference - Basis. Covers conditional directives that gate required / forbidden / applied field rules on the value or presence of other fields.


Conditional Directives

Directive Value Effect
$requiredIf field(cond) [fields] Listed fields required when condition on field is true
$requiredIfNot field(cond) [fields] Listed fields required when condition on field is false
$requiredIfExist field [fields] Listed fields required when field exists
$requiredIfNotExist field [fields] Listed fields required when field is absent
$forbiddenIf field(cond) [fields] Listed fields forbidden when condition on field is true
$forbiddenIfNot field(cond) [fields] Listed fields forbidden when condition on field is false
$forbiddenIfExist field [fields] Listed fields forbidden when field exists
$forbiddenIfNotExist field [fields] Listed fields forbidden when field is absent
$appliedIf field(cond) {...} Structure applied when condition on field is true
$appliedIfExist field {...} Structure applied when field exists
$appliedIfNotExist field {...} Structure applied when field is absent
$required [fields] Unconditional required fields
$forbidden [fields] Unconditional forbidden fields
$atLeastOne [fields] At least one field from group must be present
$mutuallyExclusive [fields] At most one field from group may be present
$exactlyOne [fields] Exactly one field from group must be present
$allOrNone [fields] All fields in group present, or none

Condition syntax: field(values) or field(min..max) or field(_TypeGuard_) or field(null) or field(%Compute)

%Compute as operand: the expression runs with it bound to the field, the condition holds when it yields true.

Suffix mechanism: To declare several independent groups of $atLeastOne, $mutuallyExclusive, $exactlyOne or $allOrNone in one object, append a unique suffix: $atLeastOne_contact, $atLeastOne_address. The suffix is semantically ignored. Structural groups only.

Examples:

"$requiredIf age(<18)": ["parentConsent"]

↳ parentConsent required when age is less than 18

"$forbiddenIf status('CLOSED')": ["lastLogin"]

↳ lastLogin forbidden when status equals “CLOSED”

"$requiredIfExist shipping": ["shippingAddress"]

↳ shippingAddress required when shipping field exists

"$appliedIf status('ACTIVE')": {
  "workDays|@ (1..22)": 20
}

↳ workDays field added to schema when status equals “ACTIVE”

Switch form:

"$appliedIf paymentMethod": {
  "('CARD')": { "cardNumber|@ {16}": "1234..." },
  "('PAYPAL')": { "email|@ ~$Email~": "[email protected]" },
  "$else": { "reference|@": "REF-001" }
}

↳ Different fields required depending on paymentMethod value

$else applies when the field exists but matches no case, $notExist when it is absent; both may be present.

Inside an $appliedIf* block (incl. $else / $notExist / switch cases) you can use any directive above - except another $appliedIf* (no nesting) and $field. They check the surrounding object and apply only while the branch is active. A branch that adapts a field already declared at the parent level must use $override or $amend.

Unconditional directives:

"$required": ["firstName", "lastName"],
"$forbidden": ["internalCode"],
"$exactlyOne": ["email", "phone"],
"$allOrNone": ["street", "city", "zip"]

Null literal in conditions:

"$requiredIf status('CANCELLED', null)": ["reason"]

↳ reason required when status is "CANCELLED" or null

Path Expressions in conditions: conditions can target this., parent., or root. paths - see the Basis Quick Reference for prefix rules and type guards. A path segment may start with @ or $ (@type, $oid); . and - are not name characters.

Fields named by a directive must be declared. A typo in a trigger, a target list or a group is reported when the schema is loaded, not silently ignored - and declaring $additionalProperties: true does not change that. Conditions are type-checked against the field too: type('true') on a boolean field is an error, because a quoted literal is a string. Same for a condition that can never be true, such as a value outside the nomenclature bound to the field - each listed value is judged on its own, a valid sibling does not excuse it.


Okyline® is a registered trademark of Akwatype.