Use conditional keywords when required fields depend on other values.Documentation Index
Fetch the complete documentation index at: https://docs.dottxt.ai/llms.txt
Use this file to discover all available pages before exploring further.
Supported keywords
| Keyword | What it does |
|---|---|
if / then / else | Apply different schemas based on a condition |
dependentRequired | Require companion fields when a field is present |
if / then / else
Validate one branch when a condition matches, and another branch otherwise.
Pydantic and Zod examples are omitted for this example because there is no direct keyword mapping for JSON Schema
if/then/else.JSON Schema
delivery_method is “shipping”, then the property address is required. Otherwise, it’s the property pickup_location that is required.
Multiple independent conditions
UseallOf with multiple if/then blocks when separate rules should all apply.
JSON Schema
account_type is equal to “business” then the property company_name is required and, independently of it, if the property country is equal to “US”, then the property state is required. Thus, if both conditions evaluate to true, then both properties company_name and state are required.
dependentRequired
Require companion fields when a field is present.
JSON Schema
email is present, then the property email_verified must also be present. Similarly, if the property phone is present, then the property phone_verified must also be present.
Use dependentRequired for presence-based dependencies, and if/then/else for value-based dependencies.