Version: 1.7.0 Date: May 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.
| 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)
Suffix mechanism: To declare multiple independent groups of the same directive in one object, append a unique suffix:
$atLeastOne_contact,$atLeastOne_address, etc. The suffix is semantically ignored.
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~": "a@b.c" },
"$else": { "reference|@": "REF-001" }
}↳ Different fields required depending on paymentMethod value
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.
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.
Okyline® is a registered trademark of Akwatype.