Some fields only make sense in certain contexts. Requiring an email address when the user chose SMS delivery is noise; omitting a phone number when they chose SMS is a bug. A discriminated union encodes this cleanly: one branch for email, one branch for SMS.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.
Use case
A checkout flow wheredelivery_method decides which contact details are mandatory. When the user wants email delivery, you need their email address. When they want SMS, you need their phone number. Both should never be required simultaneously.
Schema pattern
Prompt snippet
Example outputs
Why this works
TheanyOf branches split the payload into two exact shapes. The email branch requires email, and the SMS branch requires phone. Because delivery_method is fixed with const in each branch, the model cannot mix fields across branches, so anyOf is equivalent to oneOf here.